Skip to content

Commit

Permalink
STYLE: Inconsistent namespace - apply (pandas-dev#39992)
Browse files Browse the repository at this point in the history
Fix inconsistent namespace in apply directory.
  • Loading branch information
punitvara committed Feb 24, 2021
1 parent dec7d21 commit 4780e6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions pandas/tests/apply/test_frame_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,13 @@ def test_frame_apply_dont_convert_datetime64():

def test_apply_non_numpy_dtype():
# GH 12244
df = DataFrame({"dt": pd.date_range("2015-01-01", periods=3, tz="Europe/Brussels")})
df = DataFrame({"dt": date_range("2015-01-01", periods=3, tz="Europe/Brussels")})
result = df.apply(lambda x: x)
tm.assert_frame_equal(result, df)

result = df.apply(lambda x: x + pd.Timedelta("1day"))
expected = DataFrame(
{"dt": pd.date_range("2015-01-02", periods=3, tz="Europe/Brussels")}
{"dt": date_range("2015-01-02", periods=3, tz="Europe/Brussels")}
)
tm.assert_frame_equal(result, expected)

Expand Down Expand Up @@ -1149,11 +1149,11 @@ def test_agg_transform(axis, float_frame):
result = float_frame.apply([np.sqrt], axis=axis)
expected = f_sqrt.copy()
if axis in {0, "index"}:
expected.columns = pd.MultiIndex.from_product(
expected.columns = MultiIndex.from_product(
[float_frame.columns, ["sqrt"]]
)
else:
expected.index = pd.MultiIndex.from_product([float_frame.index, ["sqrt"]])
expected.index = MultiIndex.from_product([float_frame.index, ["sqrt"]])
tm.assert_frame_equal(result, expected)

# multiple items in list
Expand All @@ -1162,11 +1162,11 @@ def test_agg_transform(axis, float_frame):
result = float_frame.apply([np.abs, np.sqrt], axis=axis)
expected = zip_frames([f_abs, f_sqrt], axis=other_axis)
if axis in {0, "index"}:
expected.columns = pd.MultiIndex.from_product(
expected.columns = MultiIndex.from_product(
[float_frame.columns, ["absolute", "sqrt"]]
)
else:
expected.index = pd.MultiIndex.from_product(
expected.index = MultiIndex.from_product(
[float_frame.index, ["absolute", "sqrt"]]
)
tm.assert_frame_equal(result, expected)
Expand Down Expand Up @@ -1228,7 +1228,7 @@ def test_agg_multiple_mixed_no_warning():
"A": [1, 2, 3],
"B": [1.0, 2.0, 3.0],
"C": ["foo", "bar", "baz"],
"D": pd.date_range("20130101", periods=3),
"D": date_range("20130101", periods=3),
}
)
expected = DataFrame(
Expand Down Expand Up @@ -1343,7 +1343,7 @@ def test_nuiscance_columns():
"A": [1, 2, 3],
"B": [1.0, 2.0, 3.0],
"C": ["foo", "bar", "baz"],
"D": pd.date_range("20130101", periods=3),
"D": date_range("20130101", periods=3),
}
)

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/apply/test_series_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ def test_transform(string_series):
# multiple items in list
# these are in the order as if we are applying both functions per
# series and then concatting
expected = pd.concat([f_sqrt, f_abs], axis=1)
expected = concat([f_sqrt, f_abs], axis=1)
expected.columns = ["sqrt", "absolute"]
result = string_series.apply([np.sqrt, np.abs])
tm.assert_frame_equal(result, expected)

# dict, provide renaming
expected = pd.concat([f_sqrt, f_abs], axis=1)
expected = concat([f_sqrt, f_abs], axis=1)
expected.columns = ["foo", "bar"]
expected = expected.unstack().rename("series")

Expand Down

0 comments on commit 4780e6b

Please sign in to comment.