Skip to content

Commit 2ce5585

Browse files
authored
TST/REF: misplaced DataFrame.append test (#38568)
1 parent cec2f5f commit 2ce5585

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

pandas/tests/frame/methods/test_append.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
import pytest
33

44
import pandas as pd
5-
from pandas import DataFrame, Series, Timestamp
5+
from pandas import DataFrame, Series, Timestamp, date_range, timedelta_range
66
import pandas._testing as tm
77

88

99
class TestDataFrameAppend:
10-
@pytest.mark.parametrize("klass", [Series, DataFrame])
11-
def test_append_multiindex(self, multiindex_dataframe_random_data, klass):
10+
def test_append_multiindex(self, multiindex_dataframe_random_data, frame_or_series):
1211
obj = multiindex_dataframe_random_data
13-
if klass is Series:
12+
if frame_or_series is Series:
1413
obj = obj["A"]
1514

1615
a = obj[:5]
@@ -209,3 +208,17 @@ def test_other_dtypes(self, data, dtype):
209208
result = df.append(df.iloc[0]).iloc[-1]
210209
expected = Series(data, name=0, dtype=dtype)
211210
tm.assert_series_equal(result, expected)
211+
212+
@pytest.mark.parametrize("dtype", ["datetime64[ns]", "timedelta64[ns]"])
213+
def test_append_numpy_bug_1681(self, dtype):
214+
# another datetime64 bug
215+
if dtype == "datetime64[ns]":
216+
index = date_range("2011/1/1", "2012/1/1", freq="W-FRI")
217+
else:
218+
index = timedelta_range("1 days", "10 days", freq="2D")
219+
220+
df = DataFrame()
221+
other = DataFrame({"A": "foo", "B": index}, index=index)
222+
223+
result = df.append(other)
224+
assert (result["B"] == index).all()

pandas/tests/indexes/datetimes/test_datetime.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,6 @@ def test_groupby_function_tuple_1677(self):
216216
result = monthly_group.mean()
217217
assert isinstance(result.index[0], tuple)
218218

219-
def test_append_numpy_bug_1681(self):
220-
# another datetime64 bug
221-
dr = date_range("2011/1/1", "2012/1/1", freq="W-FRI")
222-
a = DataFrame()
223-
c = DataFrame({"A": "foo", "B": dr}, index=dr)
224-
225-
result = a.append(c)
226-
assert (result["B"] == dr).all()
227-
228219
def test_isin(self):
229220
index = tm.makeDateIndex(4)
230221
result = index.isin(index)

pandas/tests/indexes/timedeltas/test_timedelta.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import pandas as pd
77
from pandas import (
8-
DataFrame,
98
Index,
109
Int64Index,
1110
Series,
@@ -146,16 +145,6 @@ def test_pass_TimedeltaIndex_to_index(self):
146145

147146
tm.assert_numpy_array_equal(idx.values, expected.values)
148147

149-
def test_append_numpy_bug_1681(self):
150-
151-
td = timedelta_range("1 days", "10 days", freq="2D")
152-
a = DataFrame()
153-
c = DataFrame({"A": "foo", "B": td}, index=td)
154-
str(c)
155-
156-
result = a.append(c)
157-
assert (result["B"] == td).all()
158-
159148
def test_fields(self):
160149
rng = timedelta_range("1 days, 10:11:12.100123456", periods=2, freq="s")
161150
tm.assert_index_equal(rng.days, Index([1, 1], dtype="int64"))

0 commit comments

Comments
 (0)