Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
HaruguchiKazuto committed Nov 26, 2023
1 parent 26b8ee7 commit 5626043
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pandas/tests/groupby/aggregate/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ def test_agg_str_with_kwarg_axis_1_raises(df, reduction_func):
"func, expected, dtype, result_dtype_dict",
[
("sum", [5, 7, 9], "int64", {}),
("std", [4.5**0.5] * 3, int, {"i": float, "j": float, "k": float}),
("std", [4.5 ** 0.5] * 3, int, {"i": float, "j": float, "k": float}),
("var", [4.5] * 3, int, {"i": float, "j": float, "k": float}),
("sum", [5, 7, 9], "Int64", {"j": "int64"}),
("std", [4.5**0.5] * 3, "Int64", {"i": float, "j": float, "k": float}),
("std", [4.5 ** 0.5] * 3, "Int64", {"i": float, "j": float, "k": float}),
("var", [4.5] * 3, "Int64", {"i": "float64", "j": "float64", "k": "float64"}),
],
)
Expand All @@ -280,7 +280,7 @@ def test_multiindex_groupby_mixed_cols_axis1(func, expected, dtype, result_dtype
[
("sum", [[2, 4], [10, 12], [18, 20]], {10: "int64", 20: "int64"}),
# std should ideally return Int64 / Float64 #43330
("std", [[2**0.5] * 2] * 3, "float64"),
("std", [[2 ** 0.5] * 2] * 3, "float64"),
("var", [[2] * 2] * 3, {10: "float64", 20: "float64"}),
],
)
Expand Down Expand Up @@ -524,8 +524,7 @@ def test_groupby_agg_dict_with_getitem():
def test_groupby_agg_dict_dup_columns():
# GH#55006
df = DataFrame(
[[1, 2, 3, 4], [1, 3, 4, 5], [2, 4, 5, 6]],
columns=["a", "b", "c", "c"],
[[1, 2, 3, 4], [1, 3, 4, 5], [2, 4, 5, 6]], columns=["a", "b", "c", "c"],
)
gb = df.groupby("a")
result = gb.agg({"b": "sum"})
Expand Down Expand Up @@ -889,11 +888,12 @@ def f(x):
raise ValueError("length must not be 0")
return len(x)

df = DataFrame({"A": pd.Categorical(['a', 'a'],
categories=['a', 'b', 'c']), "B": [1, 1]})
msg = 'length must not be 0'
df = DataFrame(
{"A": pd.Categorical(["a", "a"], categories=["a", "b", "c"]), "B": [1, 1]}
)
msg = "length must not be 0"
with pytest.raises(ValueError, match=msg):
df.groupby('A').agg(f)
df.groupby("A").agg(f)

def test_agg_namedtuple(self):
df = DataFrame({"A": [0, 1], "B": [1, 2]})
Expand Down Expand Up @@ -1198,7 +1198,7 @@ def test_agg_with_one_lambda(self):
# check pd.NameAgg case
result1 = df.groupby(by="kind").agg(
height_sqr_min=pd.NamedAgg(
column="height", aggfunc=lambda x: np.min(x**2)
column="height", aggfunc=lambda x: np.min(x ** 2)
),
height_max=pd.NamedAgg(column="height", aggfunc="max"),
weight_max=pd.NamedAgg(column="weight", aggfunc="max"),
Expand All @@ -1207,7 +1207,7 @@ def test_agg_with_one_lambda(self):

# check agg(key=(col, aggfunc)) case
result2 = df.groupby(by="kind").agg(
height_sqr_min=("height", lambda x: np.min(x**2)),
height_sqr_min=("height", lambda x: np.min(x ** 2)),
height_max=("height", "max"),
weight_max=("weight", "max"),
)
Expand Down Expand Up @@ -1244,7 +1244,7 @@ def test_agg_multiple_lambda(self):

# check agg(key=(col, aggfunc)) case
result1 = df.groupby(by="kind").agg(
height_sqr_min=("height", lambda x: np.min(x**2)),
height_sqr_min=("height", lambda x: np.min(x ** 2)),
height_max=("height", "max"),
weight_max=("weight", "max"),
height_max_2=("height", lambda x: np.max(x)),
Expand All @@ -1255,7 +1255,7 @@ def test_agg_multiple_lambda(self):
# check pd.NamedAgg case
result2 = df.groupby(by="kind").agg(
height_sqr_min=pd.NamedAgg(
column="height", aggfunc=lambda x: np.min(x**2)
column="height", aggfunc=lambda x: np.min(x ** 2)
),
height_max=pd.NamedAgg(column="height", aggfunc="max"),
weight_max=pd.NamedAgg(column="weight", aggfunc="max"),
Expand Down

0 comments on commit 5626043

Please sign in to comment.