Skip to content

Commit 4502c2e

Browse files
authored
STYLE: Inconsistent namespace - apply (pandas-dev#39992) (pandas-dev#40029)
Fix inconsistent namespace in apply directory.
1 parent 935a8c0 commit 4502c2e

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

pandas/tests/apply/test_frame_apply.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -748,13 +748,13 @@ def test_frame_apply_dont_convert_datetime64():
748748

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

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

@@ -1149,11 +1149,9 @@ def test_agg_transform(axis, float_frame):
11491149
result = float_frame.apply([np.sqrt], axis=axis)
11501150
expected = f_sqrt.copy()
11511151
if axis in {0, "index"}:
1152-
expected.columns = pd.MultiIndex.from_product(
1153-
[float_frame.columns, ["sqrt"]]
1154-
)
1152+
expected.columns = MultiIndex.from_product([float_frame.columns, ["sqrt"]])
11551153
else:
1156-
expected.index = pd.MultiIndex.from_product([float_frame.index, ["sqrt"]])
1154+
expected.index = MultiIndex.from_product([float_frame.index, ["sqrt"]])
11571155
tm.assert_frame_equal(result, expected)
11581156

11591157
# multiple items in list
@@ -1162,11 +1160,11 @@ def test_agg_transform(axis, float_frame):
11621160
result = float_frame.apply([np.abs, np.sqrt], axis=axis)
11631161
expected = zip_frames([f_abs, f_sqrt], axis=other_axis)
11641162
if axis in {0, "index"}:
1165-
expected.columns = pd.MultiIndex.from_product(
1163+
expected.columns = MultiIndex.from_product(
11661164
[float_frame.columns, ["absolute", "sqrt"]]
11671165
)
11681166
else:
1169-
expected.index = pd.MultiIndex.from_product(
1167+
expected.index = MultiIndex.from_product(
11701168
[float_frame.index, ["absolute", "sqrt"]]
11711169
)
11721170
tm.assert_frame_equal(result, expected)
@@ -1228,7 +1226,7 @@ def test_agg_multiple_mixed_no_warning():
12281226
"A": [1, 2, 3],
12291227
"B": [1.0, 2.0, 3.0],
12301228
"C": ["foo", "bar", "baz"],
1231-
"D": pd.date_range("20130101", periods=3),
1229+
"D": date_range("20130101", periods=3),
12321230
}
12331231
)
12341232
expected = DataFrame(
@@ -1343,7 +1341,7 @@ def test_nuiscance_columns():
13431341
"A": [1, 2, 3],
13441342
"B": [1.0, 2.0, 3.0],
13451343
"C": ["foo", "bar", "baz"],
1346-
"D": pd.date_range("20130101", periods=3),
1344+
"D": date_range("20130101", periods=3),
13471345
}
13481346
)
13491347

pandas/tests/apply/test_series_apply.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,13 @@ def test_transform(string_series):
255255
# multiple items in list
256256
# these are in the order as if we are applying both functions per
257257
# series and then concatting
258-
expected = pd.concat([f_sqrt, f_abs], axis=1)
258+
expected = concat([f_sqrt, f_abs], axis=1)
259259
expected.columns = ["sqrt", "absolute"]
260260
result = string_series.apply([np.sqrt, np.abs])
261261
tm.assert_frame_equal(result, expected)
262262

263263
# dict, provide renaming
264-
expected = pd.concat([f_sqrt, f_abs], axis=1)
264+
expected = concat([f_sqrt, f_abs], axis=1)
265265
expected.columns = ["foo", "bar"]
266266
expected = expected.unstack().rename("series")
267267

0 commit comments

Comments
 (0)