Skip to content

REF: collect tests by method #37271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pandas/tests/frame/methods/test_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,24 @@ def test_drop_preserve_names(self):

result = df.drop([(0, 2)])
assert result.index.names == ("one", "two")

@pytest.mark.parametrize(
"operation", ["__iadd__", "__isub__", "__imul__", "__ipow__"]
)
@pytest.mark.parametrize("inplace", [False, True])
def test_inplace_drop_and_operation(self, operation, inplace):
# GH#30484
df = pd.DataFrame({"x": range(5)})
expected = df.copy()
df["y"] = range(5)
y = df["y"]

with tm.assert_produces_warning(None):
if inplace:
df.drop("y", axis=1, inplace=inplace)
else:
df = df.drop("y", axis=1, inplace=inplace)

# Perform operation and check result
getattr(y, operation)(1)
tm.assert_frame_equal(df, expected)
21 changes: 0 additions & 21 deletions pandas/tests/frame/test_axis_select_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,24 +488,3 @@ def test_reindex_multi_categorical_time(self):
result = df2.reindex(midx)
expected = pd.DataFrame({"a": [0, 1, 2, 3, 4, 5, 6, np.nan, 8]}, index=midx)
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize(
"operation", ["__iadd__", "__isub__", "__imul__", "__ipow__"]
)
@pytest.mark.parametrize("inplace", [False, True])
def test_inplace_drop_and_operation(self, operation, inplace):
# GH 30484
df = pd.DataFrame({"x": range(5)})
expected = df.copy()
df["y"] = range(5)
y = df["y"]

with tm.assert_produces_warning(None):
if inplace:
df.drop("y", axis=1, inplace=inplace)
else:
df = df.drop("y", axis=1, inplace=inplace)

# Perform operation and check result
getattr(y, operation)(1)
tm.assert_frame_equal(df, expected)
7 changes: 7 additions & 0 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 +2677,13 @@ def test_with_mismatched_index_length_raises(self):
with pytest.raises(ValueError, match="Shape of passed values"):
DataFrame(dti, index=range(4))

def test_frame_ctor_datetime64_column(self):
rng = date_range("1/1/2000 00:00:00", "1/1/2000 1:59:50", freq="10s")
dates = np.asarray(rng)

df = DataFrame({"A": np.random.randn(len(rng)), "B": dates})
assert np.issubdtype(df["B"].dtype, np.dtype("M8[ns]"))


class TestDataFrameConstructorWithDatetimeTZ:
def test_from_dict(self):
Expand Down
9 changes: 1 addition & 8 deletions pandas/tests/frame/test_timeseries.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import numpy as np

import pandas as pd
from pandas import DataFrame, date_range, to_datetime
from pandas import DataFrame, to_datetime
import pandas._testing as tm


class TestDataFrameTimeSeriesMethods:
def test_frame_ctor_datetime64_column(self):
rng = date_range("1/1/2000 00:00:00", "1/1/2000 1:59:50", freq="10s")
dates = np.asarray(rng)

df = DataFrame({"A": np.random.randn(len(rng)), "B": dates})
assert np.issubdtype(df["B"].dtype, np.dtype("M8[ns]"))

def test_frame_append_datetime64_col_other_units(self):
n = 100

Expand Down