Skip to content

Commit 9544213

Browse files
committed
CLN remove unnecessary trailing commas in groupby tests
1 parent 0bc407a commit 9544213

8 files changed

+28
-31
lines changed

pandas/tests/groupby/aggregate/test_numba.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def func_1(values, index):
138138
"min",
139139
{"B": ["min", "max"], "C": "sum"},
140140
NamedAgg(column="B", aggfunc="min"),
141-
],
141+
]
142142
)
143143
def test_multifunc_notimplimented(agg_func):
144144
data = DataFrame(

pandas/tests/groupby/test_apply.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def f(g):
136136
"GH12155",
137137
"GH20084",
138138
"GH21417",
139-
],
139+
]
140140
)
141141
def test_group_apply_once_per_group(df, group_names):
142142
# GH2936, GH7739, GH10519, GH2656, GH12155, GH20084, GH21417
@@ -800,7 +800,7 @@ def test_func_returns_object():
800800

801801
@pytest.mark.parametrize(
802802
"group_column_dtlike",
803-
[datetime.today(), datetime.today().date(), datetime.today().time()],
803+
[datetime.today(), datetime.today().date(), datetime.today().time()]
804804
)
805805
def test_apply_datetime_issue(group_column_dtlike):
806806
# GH-28247
@@ -899,7 +899,7 @@ def test_groupby_apply_datetime_result_dtypes():
899899
pd.interval_range(0, 3),
900900
pd.period_range("2020", periods=3, freq="D"),
901901
pd.MultiIndex.from_tuples([("a", 0), ("a", 1), ("b", 0)]),
902-
],
902+
]
903903
)
904904
def test_apply_index_has_complex_internals(index):
905905
# GH 31248
@@ -922,7 +922,7 @@ def test_apply_index_has_complex_internals(index):
922922
lambda x: [{n: i} for (n, i) in enumerate(x.index.to_list())],
923923
[[{0: 0}, {1: 1}], [{0: 2}, {1: 3}]],
924924
),
925-
],
925+
]
926926
)
927927
def test_apply_function_returns_non_pandas_non_scalar(function, expected_values):
928928
# GH 31441
@@ -947,7 +947,7 @@ def fct(group):
947947

948948

949949
@pytest.mark.parametrize(
950-
"function", [lambda gr: gr.index, lambda gr: gr.index + 1 - 1],
950+
"function", [lambda gr: gr.index, lambda gr: gr.index + 1 - 1]
951951
)
952952
def test_apply_function_index_return(function):
953953
# GH: 22541

pandas/tests/groupby/test_categorical.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ def test_preserve_categorical_dtype():
762762
("last", ["fourth", "third"]),
763763
("min", ["fourth", "first"]),
764764
("max", ["second", "third"]),
765-
],
765+
]
766766
)
767767
def test_preserve_on_ordered_ops(func, values):
768768
# gh-18502
@@ -1102,7 +1102,7 @@ def test_groupby_multiindex_categorical_datetime():
11021102
}
11031103
),
11041104
),
1105-
],
1105+
]
11061106
)
11071107
def test_groupby_agg_observed_true_single_column(as_index, expected):
11081108
# GH-23970
@@ -1233,7 +1233,7 @@ def test_seriesgroupby_observed_false_or_none(df_cat, observed, operation):
12331233
),
12341234
[2, 2, 4, 4, np.nan, np.nan, 1, 1, np.nan, np.nan, 3, 3],
12351235
),
1236-
],
1236+
]
12371237
)
12381238
def test_seriesgroupby_observed_apply_dict(df_cat, observed, index, data):
12391239
# GH 24880
@@ -1435,7 +1435,7 @@ def test_series_groupby_categorical_aggregation_getitem():
14351435

14361436
@pytest.mark.parametrize(
14371437
"func, expected_values",
1438-
[(pd.Series.nunique, [1, 1, 2]), (pd.Series.count, [1, 2, 2])],
1438+
[(pd.Series.nunique, [1, 1, 2]), (pd.Series.count, [1, 2, 2])]
14391439
)
14401440
def test_groupby_agg_categorical_columns(func, expected_values):
14411441
# 31256

pandas/tests/groupby/test_groupby.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ def test_transform_doesnt_clobber_ints():
16341634

16351635
@pytest.mark.parametrize(
16361636
"sort_column",
1637-
["ints", "floats", "strings", ["ints", "floats"], ["ints", "strings"]],
1637+
["ints", "floats", "strings", ["ints", "floats"], ["ints", "strings"]]
16381638
)
16391639
@pytest.mark.parametrize(
16401640
"group_column", ["int_groups", "string_groups", ["int_groups", "string_groups"]]
@@ -1925,7 +1925,7 @@ def test_groupby_axis_1(group_name):
19251925
]
19261926
},
19271927
),
1928-
],
1928+
]
19291929
)
19301930
def test_shift_bfill_ffill_tz(tz_naive_fixture, op, expected):
19311931
# GH19995, GH27992: Check that timezone does not drop in shift, bfill, and ffill
@@ -2042,7 +2042,7 @@ def test_groupby_list_level():
20422042
[
20432043
(5, "{0: [0], 1: [1], 2: [2], 3: [3], 4: [4]}"),
20442044
(4, "{0: [0], 1: [1], 2: [2], 3: [3], ...}"),
2045-
],
2045+
]
20462046
)
20472047
def test_groups_repr_truncates(max_seq_items, expected):
20482048
# GH 1135
@@ -2097,7 +2097,7 @@ def test_group_on_two_row_multiindex_returns_one_tuple_key():
20972097
(Series, "squeeze", True),
20982098
(Series, "observed", True),
20992099
(Series, "dropna", False),
2100-
],
2100+
]
21012101
)
21022102
@pytest.mark.filterwarnings(
21032103
"ignore:The `squeeze` parameter is deprecated:FutureWarning"

pandas/tests/groupby/test_groupby_dropna.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"e": [13.0, 12.0, 1.0],
2323
},
2424
),
25-
],
25+
]
2626
)
2727
def test_groupby_dropna_multi_index_dataframe_nan_in_one_group(
2828
dropna, tuples, outputs, nulls_fixture
@@ -65,7 +65,7 @@ def test_groupby_dropna_multi_index_dataframe_nan_in_one_group(
6565
"e": [12.0, 13.0, 1.0, 1.0],
6666
},
6767
),
68-
],
68+
]
6969
)
7070
def test_groupby_dropna_multi_index_dataframe_nan_in_two_groups(
7171
dropna, tuples, outputs, nulls_fixture, nulls_fixture2
@@ -105,7 +105,7 @@ def test_groupby_dropna_multi_index_dataframe_nan_in_two_groups(
105105
"d": [1.0, 13.0, 12.0],
106106
},
107107
),
108-
],
108+
]
109109
)
110110
def test_groupby_dropna_normal_index_dataframe(dropna, idx, outputs):
111111
# GH 3729
@@ -132,7 +132,7 @@ def test_groupby_dropna_normal_index_dataframe(dropna, idx, outputs):
132132
["a", "a", "b", np.nan],
133133
pd.Series([3, 3, 3], index=["a", "b", np.nan]),
134134
),
135-
],
135+
]
136136
)
137137
def test_groupby_dropna_series_level(dropna, idx, expected):
138138
ser = pd.Series([1, 2, 3, 3], index=idx)
@@ -149,7 +149,7 @@ def test_groupby_dropna_series_level(dropna, idx, expected):
149149
False,
150150
pd.Series([210.0, 350.0, 20.0], index=["a", "b", np.nan], name="Max Speed"),
151151
),
152-
],
152+
]
153153
)
154154
def test_groupby_dropna_series_by(dropna, expected):
155155
ser = pd.Series(
@@ -176,7 +176,7 @@ def test_groupby_dropna_series_by(dropna, expected):
176176
pd.DataFrame({"B": [2, 2, 1, 1]}),
177177
pd.Series(data=[2, 2, 1, 1], name="B"),
178178
),
179-
],
179+
]
180180
)
181181
def test_slice_groupby_then_transform(dropna, df_expected, s_expected):
182182
# GH35014
@@ -213,7 +213,7 @@ def test_slice_groupby_then_transform(dropna, df_expected, s_expected):
213213
"e": [1.0, 12.0, 1.0],
214214
},
215215
),
216-
],
216+
]
217217
)
218218
def test_groupby_dropna_multi_index_dataframe_agg(dropna, tuples, outputs):
219219
# GH 3729
@@ -244,11 +244,9 @@ def test_groupby_dropna_multi_index_dataframe_agg(dropna, tuples, outputs):
244244
(pd.Timestamp("2020-01-01"), pd.Timestamp("2020-02-01")),
245245
(pd.Timedelta("-2 days"), pd.Timedelta("-1 days")),
246246
(pd.Period("2020-01-01"), pd.Period("2020-02-01")),
247-
],
248-
)
249-
@pytest.mark.parametrize(
250-
"dropna, values", [(True, [12, 3]), (False, [12, 3, 6],)],
247+
]
251248
)
249+
@pytest.mark.parametrize("dropna, values", [(True, [12, 3]), (False, [12, 3, 6],)])
252250
def test_groupby_dropna_datetime_like_data(
253251
dropna, values, datetime1, datetime2, unique_nulls_fixture, unique_nulls_fixture2
254252
):

pandas/tests/groupby/test_groupby_subclass.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[
1313
tm.SubclassedDataFrame({"A": np.arange(0, 10)}),
1414
tm.SubclassedSeries(np.arange(0, 10), name="A"),
15-
],
15+
]
1616
)
1717
@pytest.mark.filterwarnings("ignore:tshift is deprecated:FutureWarning")
1818
def test_groupby_preserves_subclass(obj, groupby_func):
@@ -51,9 +51,7 @@ def test_groupby_preserves_subclass(obj, groupby_func):
5151
tm.assert_series_equal(result1, result2)
5252

5353

54-
@pytest.mark.parametrize(
55-
"obj", [DataFrame, tm.SubclassedDataFrame],
56-
)
54+
@pytest.mark.parametrize("obj", [DataFrame, tm.SubclassedDataFrame])
5755
def test_groupby_resample_preserves_subclass(obj):
5856
# GH28330 -- preserve subclass through groupby.resample()
5957

pandas/tests/groupby/test_size.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def test_size_on_categorical(as_index):
5353
result = df.groupby(["A", "B"], as_index=as_index).size()
5454

5555
expected = DataFrame(
56-
[[1, 1, 1], [1, 2, 0], [2, 1, 0], [2, 2, 1]], columns=["A", "B", "size"],
56+
[[1, 1, 1], [1, 2, 0], [2, 1, 0], [2, 2, 1]],
57+
columns=["A", "B", "size"]
5758
)
5859
expected["A"] = expected["A"].astype("category")
5960
if as_index:

pandas/tests/groupby/test_timegrouper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,6 @@ def test_grouper_period_index(self):
780780
result = period_series.groupby(period_series.index.month).sum()
781781

782782
expected = pd.Series(
783-
range(0, periods), index=Index(range(1, periods + 1), name=index.name),
783+
range(0, periods), index=Index(range(1, periods + 1), name=index.name)
784784
)
785785
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)