Skip to content

Comma cleanup for Issue #35925 #35970

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

Closed
wants to merge 1 commit into from
Closed
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
84 changes: 42 additions & 42 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
isna,
notna,
to_datetime,
to_timedelta,
to_timedelta
)
import pandas._testing as tm
import pandas.core.algorithms as algorithms
Expand All @@ -34,7 +34,7 @@ def assert_stat_op_calc(
check_dates=False,
rtol=1e-5,
atol=1e-8,
skipna_alternative=None,
skipna_alternative=None
):
"""
Check that operator opname works as advertised on frame
Expand Down Expand Up @@ -90,15 +90,15 @@ def wrapper(x):
frame.apply(wrapper),
check_dtype=check_dtype,
rtol=rtol,
atol=atol,
atol=atol
)
# HACK: win32
tm.assert_series_equal(
result1,
frame.apply(wrapper, axis=1),
check_dtype=False,
rtol=rtol,
atol=atol,
atol=atol
)
else:
skipna_wrapper = alternative
Expand All @@ -110,13 +110,13 @@ def wrapper(x):
frame.apply(skipna_wrapper),
check_dtype=check_dtype,
rtol=rtol,
atol=atol,
atol=atol
)

if opname in ["sum", "prod"]:
expected = frame.apply(skipna_wrapper, axis=1)
tm.assert_series_equal(
result1, expected, check_dtype=False, rtol=rtol, atol=atol,
result1, expected, check_dtype=False, rtol=rtol, atol=atol
)

# check dtypes
Expand Down Expand Up @@ -333,7 +333,7 @@ def kurt(x):
float_frame_with_na,
has_skipna=False,
check_dtype=False,
check_dates=True,
check_dates=True
)

# GH#32571 check_less_precise is needed on apparently-random
Expand All @@ -344,7 +344,7 @@ def kurt(x):
np.sum,
mixed_float_frame.astype("float32"),
check_dtype=False,
rtol=1e-3,
rtol=1e-3
)

assert_stat_op_calc(
Expand All @@ -366,7 +366,7 @@ def kurt(x):
float_frame_with_na,
has_skipna=False,
check_dtype=False,
check_dates=True,
check_dates=True
)

try:
Expand Down Expand Up @@ -399,14 +399,14 @@ def test_stat_operators_attempt_obj_array(self, method):
"a": [
-0.00049987540199591344,
-0.0016467257772919831,
0.00067695870775883013,
0.00067695870775883013
],
"b": [-0, -0, 0.0],
"c": [
0.00031111847529610595,
0.0014902627951905339,
-0.00094099200035979691,
],
-0.00094099200035979691
]
}
df1 = DataFrame(data, index=["foo", "bar", "baz"], dtype="O")

Expand All @@ -427,7 +427,7 @@ def test_mixed_ops(self, op):
{
"int": [1, 2, 3, 4],
"float": [1.0, 2.0, 3.0, 4.0],
"str": ["a", "b", "c", "d"],
"str": ["a", "b", "c", "d"]
}
)

Expand All @@ -444,7 +444,7 @@ def test_reduce_mixed_frame(self):
{
"bool_data": [True, True, False, False, False],
"int_data": [10, 20, 30, 40, 50],
"string_data": ["a", "b", "c", "d", "e"],
"string_data": ["a", "b", "c", "d", "e"]
}
)
df.reindex(columns=["bool_data", "int_data", "string_data"])
Expand Down Expand Up @@ -500,7 +500,7 @@ def test_mean_mixed_string_decimal(self):
{"A": 2, "B": None, "C": Decimal("572.00")},
{"A": 4, "B": None, "C": Decimal("609.00")},
{"A": 3, "B": None, "C": Decimal("820.00")},
{"A": 5, "B": None, "C": Decimal("1223.00")},
{"A": 5, "B": None, "C": Decimal("1223.00")}
]

df = pd.DataFrame(d)
Expand Down Expand Up @@ -570,7 +570,7 @@ def test_sem(self, datetime_frame):
def test_kurt(self):
index = MultiIndex(
levels=[["bar"], ["one", "two", "three"], [0, 1]],
codes=[[0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]],
codes=[[0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]]
)
df = DataFrame(np.random.randn(6, 3), index=index)

Expand All @@ -592,8 +592,8 @@ def test_kurt(self):
"D": ["a"],
"E": Categorical(["a"], categories=["a"]),
"F": to_datetime(["2000-1-2"]),
"G": to_timedelta(["1 days"]),
},
"G": to_timedelta(["1 days"])
}
),
(
False,
Expand All @@ -604,8 +604,8 @@ def test_kurt(self):
"D": np.array([np.nan], dtype=object),
"E": Categorical([np.nan], categories=["a"]),
"F": [pd.NaT],
"G": to_timedelta([pd.NaT]),
},
"G": to_timedelta([pd.NaT])
}
),
(
True,
Expand All @@ -616,8 +616,8 @@ def test_kurt(self):
"K": Categorical(["a", np.nan, np.nan, np.nan], categories=["a"]),
"L": to_datetime(["2000-1-2", "NaT", "NaT", "NaT"]),
"M": to_timedelta(["1 days", "nan", "nan", "nan"]),
"N": [0, 1, 2, 3],
},
"N": [0, 1, 2, 3]
}
),
(
False,
Expand All @@ -628,10 +628,10 @@ def test_kurt(self):
"K": Categorical([np.nan, "a", np.nan, np.nan], categories=["a"]),
"L": to_datetime(["NaT", "2000-1-2", "NaT", "NaT"]),
"M": to_timedelta(["nan", "1 days", "nan", "nan"]),
"N": [0, 1, 2, 3],
},
),
],
"N": [0, 1, 2, 3]
}
)
]
)
def test_mode_dropna(self, dropna, expected):

Expand All @@ -650,7 +650,7 @@ def test_mode_dropna(self, dropna, expected):
"K": Categorical(["a", np.nan, "a", np.nan]),
"L": to_datetime(["2000-1-2", "2000-1-2", "NaT", "NaT"]),
"M": to_timedelta(["1 days", "nan", "1 days", "nan"]),
"N": np.arange(4, dtype="int64"),
"N": np.arange(4, dtype="int64")
}
)

Expand All @@ -676,7 +676,7 @@ def test_operators_timedelta64(self):
dict(
A=date_range("2012-1-1", periods=3, freq="D"),
B=date_range("2012-1-2", periods=3, freq="D"),
C=Timestamp("20120101") - timedelta(minutes=5, seconds=5),
C=Timestamp("20120101") - timedelta(minutes=5, seconds=5)
)
)

Expand Down Expand Up @@ -721,9 +721,9 @@ def test_operators_timedelta64(self):
"foo",
1,
1.0,
Timestamp("20130101"),
Timestamp("20130101")
],
index=mixed.columns,
index=mixed.columns
)
tm.assert_series_equal(result, expected)

Expand All @@ -747,7 +747,7 @@ def test_operators_timedelta64(self):
df = DataFrame(
{
"time": date_range("20130102", periods=5),
"time2": date_range("20130105", periods=5),
"time2": date_range("20130105", periods=5)
}
)
df["off1"] = df["time2"] - df["time"]
Expand Down Expand Up @@ -871,7 +871,7 @@ def test_mean_datetimelike(self):
"A": np.arange(3),
"B": pd.date_range("2016-01-01", periods=3),
"C": pd.timedelta_range("1D", periods=3),
"D": pd.period_range("2016", periods=3, freq="A"),
"D": pd.period_range("2016", periods=3, freq="A")
}
)
result = df.mean(numeric_only=True)
Expand All @@ -889,7 +889,7 @@ def test_mean_datetimelike_numeric_only_false(self):
{
"A": np.arange(3),
"B": pd.date_range("2016-01-01", periods=3),
"C": pd.timedelta_range("1D", periods=3),
"C": pd.timedelta_range("1D", periods=3)
}
)

Expand Down Expand Up @@ -974,9 +974,9 @@ def test_any_all_extra(self):
{
"A": [True, False, False],
"B": [True, True, False],
"C": [True, True, True],
"C": [True, True, True]
},
index=["a", "b", "c"],
index=["a", "b", "c"]
)
result = df[["A", "B"]].any(1)
expected = Series([True, True, False], index=["a", "b", "c"])
Expand Down Expand Up @@ -1010,7 +1010,7 @@ def test_any_datetime(self):
pd.Timestamp("1960-02-15"),
pd.Timestamp("1960-02-16"),
pd.NaT,
pd.NaT,
pd.NaT
]
df = DataFrame({"A": float_data, "B": datetime_data})

Expand All @@ -1034,7 +1034,7 @@ def test_any_all_bool_only(self):
"col1": [1, 2, 3],
"col2": [4, 5, 6],
"col3": [None, None, None],
"col4": [False, False, True],
"col4": [False, False, True]
}
)

Expand Down Expand Up @@ -1125,9 +1125,9 @@ def test_any_all_bool_only(self):
},
True,
# In 1.13.3 and 1.14 np.all(df) returns a Timedelta here
marks=[td.skip_if_np_lt("1.15")],
),
],
marks=[td.skip_if_np_lt("1.15")]
)
]
)
def test_any_all_np_func(self, func, data, expected):
# GH 19976
Expand Down Expand Up @@ -1155,7 +1155,7 @@ def test_any_all_level_axis_none_raises(self, method):
{"A": 1},
index=MultiIndex.from_product(
[["A", "B"], ["a", "b"]], names=["out", "in"]
),
)
)
xpr = "Must specify 'axis' when aggregating by level."
with pytest.raises(ValueError, match=xpr):
Expand Down Expand Up @@ -1293,7 +1293,7 @@ def test_min_max_dt64_api_consistency_empty_df(self):

@pytest.mark.parametrize(
"initial",
["2018-10-08 13:36:45+00:00", "2018-10-08 13:36:45+03:00"], # Non-UTC timezone
["2018-10-08 13:36:45+00:00", "2018-10-08 13:36:45+03:00"] # Non-UTC timezone
)
@pytest.mark.parametrize("method", ["min", "max"])
def test_preserve_timezone(self, initial: str, method):
Expand Down
Loading