Skip to content

Commit f52318c

Browse files
jbrockmendelJulianWgs
authored andcommitted
REF: collect tests by method (pandas-dev#37271)
1 parent 3c1db7a commit f52318c

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

pandas/tests/frame/methods/test_drop.py

+21
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,24 @@ def test_drop_preserve_names(self):
420420

421421
result = df.drop([(0, 2)])
422422
assert result.index.names == ("one", "two")
423+
424+
@pytest.mark.parametrize(
425+
"operation", ["__iadd__", "__isub__", "__imul__", "__ipow__"]
426+
)
427+
@pytest.mark.parametrize("inplace", [False, True])
428+
def test_inplace_drop_and_operation(self, operation, inplace):
429+
# GH#30484
430+
df = pd.DataFrame({"x": range(5)})
431+
expected = df.copy()
432+
df["y"] = range(5)
433+
y = df["y"]
434+
435+
with tm.assert_produces_warning(None):
436+
if inplace:
437+
df.drop("y", axis=1, inplace=inplace)
438+
else:
439+
df = df.drop("y", axis=1, inplace=inplace)
440+
441+
# Perform operation and check result
442+
getattr(y, operation)(1)
443+
tm.assert_frame_equal(df, expected)

pandas/tests/frame/test_axis_select_reindex.py

-21
Original file line numberDiff line numberDiff line change
@@ -488,24 +488,3 @@ def test_reindex_multi_categorical_time(self):
488488
result = df2.reindex(midx)
489489
expected = pd.DataFrame({"a": [0, 1, 2, 3, 4, 5, 6, np.nan, 8]}, index=midx)
490490
tm.assert_frame_equal(result, expected)
491-
492-
@pytest.mark.parametrize(
493-
"operation", ["__iadd__", "__isub__", "__imul__", "__ipow__"]
494-
)
495-
@pytest.mark.parametrize("inplace", [False, True])
496-
def test_inplace_drop_and_operation(self, operation, inplace):
497-
# GH 30484
498-
df = pd.DataFrame({"x": range(5)})
499-
expected = df.copy()
500-
df["y"] = range(5)
501-
y = df["y"]
502-
503-
with tm.assert_produces_warning(None):
504-
if inplace:
505-
df.drop("y", axis=1, inplace=inplace)
506-
else:
507-
df = df.drop("y", axis=1, inplace=inplace)
508-
509-
# Perform operation and check result
510-
getattr(y, operation)(1)
511-
tm.assert_frame_equal(df, expected)

pandas/tests/frame/test_constructors.py

+7
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,13 @@ def test_with_mismatched_index_length_raises(self):
26772677
with pytest.raises(ValueError, match="Shape of passed values"):
26782678
DataFrame(dti, index=range(4))
26792679

2680+
def test_frame_ctor_datetime64_column(self):
2681+
rng = date_range("1/1/2000 00:00:00", "1/1/2000 1:59:50", freq="10s")
2682+
dates = np.asarray(rng)
2683+
2684+
df = DataFrame({"A": np.random.randn(len(rng)), "B": dates})
2685+
assert np.issubdtype(df["B"].dtype, np.dtype("M8[ns]"))
2686+
26802687

26812688
class TestDataFrameConstructorWithDatetimeTZ:
26822689
def test_from_dict(self):

pandas/tests/frame/test_timeseries.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import numpy as np
22

33
import pandas as pd
4-
from pandas import DataFrame, date_range, to_datetime
4+
from pandas import DataFrame, to_datetime
55
import pandas._testing as tm
66

77

88
class TestDataFrameTimeSeriesMethods:
9-
def test_frame_ctor_datetime64_column(self):
10-
rng = date_range("1/1/2000 00:00:00", "1/1/2000 1:59:50", freq="10s")
11-
dates = np.asarray(rng)
12-
13-
df = DataFrame({"A": np.random.randn(len(rng)), "B": dates})
14-
assert np.issubdtype(df["B"].dtype, np.dtype("M8[ns]"))
15-
169
def test_frame_append_datetime64_col_other_units(self):
1710
n = 100
1811

0 commit comments

Comments
 (0)