diff --git a/pandas/tests/groupby/aggregate/test_numba.py b/pandas/tests/groupby/aggregate/test_numba.py index 29e65e938f6f9b..af5089ae3ac215 100644 --- a/pandas/tests/groupby/aggregate/test_numba.py +++ b/pandas/tests/groupby/aggregate/test_numba.py @@ -138,7 +138,7 @@ def func_1(values, index): "min", {"B": ["min", "max"], "C": "sum"}, NamedAgg(column="B", aggfunc="min"), - ], + ] ) def test_multifunc_notimplimented(agg_func): data = DataFrame( diff --git a/pandas/tests/groupby/test_apply.py b/pandas/tests/groupby/test_apply.py index a1dcb28a32c6c5..118ce8012a6d19 100644 --- a/pandas/tests/groupby/test_apply.py +++ b/pandas/tests/groupby/test_apply.py @@ -136,7 +136,7 @@ def f(g): "GH12155", "GH20084", "GH21417", - ], + ] ) def test_group_apply_once_per_group(df, group_names): # GH2936, GH7739, GH10519, GH2656, GH12155, GH20084, GH21417 @@ -800,7 +800,7 @@ def test_func_returns_object(): @pytest.mark.parametrize( "group_column_dtlike", - [datetime.today(), datetime.today().date(), datetime.today().time()], + [datetime.today(), datetime.today().date(), datetime.today().time()] ) def test_apply_datetime_issue(group_column_dtlike): # GH-28247 @@ -899,7 +899,7 @@ def test_groupby_apply_datetime_result_dtypes(): pd.interval_range(0, 3), pd.period_range("2020", periods=3, freq="D"), pd.MultiIndex.from_tuples([("a", 0), ("a", 1), ("b", 0)]), - ], + ] ) def test_apply_index_has_complex_internals(index): # GH 31248 @@ -922,7 +922,7 @@ def test_apply_index_has_complex_internals(index): lambda x: [{n: i} for (n, i) in enumerate(x.index.to_list())], [[{0: 0}, {1: 1}], [{0: 2}, {1: 3}]], ), - ], + ] ) def test_apply_function_returns_non_pandas_non_scalar(function, expected_values): # GH 31441 @@ -947,7 +947,7 @@ def fct(group): @pytest.mark.parametrize( - "function", [lambda gr: gr.index, lambda gr: gr.index + 1 - 1], + "function", [lambda gr: gr.index, lambda gr: gr.index + 1 - 1] ) def test_apply_function_index_return(function): # GH: 22541 diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index 13a32e285e70aa..554653796c7f76 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -762,7 +762,7 @@ def test_preserve_categorical_dtype(): ("last", ["fourth", "third"]), ("min", ["fourth", "first"]), ("max", ["second", "third"]), - ], + ] ) def test_preserve_on_ordered_ops(func, values): # gh-18502 @@ -1102,7 +1102,7 @@ def test_groupby_multiindex_categorical_datetime(): } ), ), - ], + ] ) def test_groupby_agg_observed_true_single_column(as_index, expected): # GH-23970 @@ -1233,7 +1233,7 @@ def test_seriesgroupby_observed_false_or_none(df_cat, observed, operation): ), [2, 2, 4, 4, np.nan, np.nan, 1, 1, np.nan, np.nan, 3, 3], ), - ], + ] ) def test_seriesgroupby_observed_apply_dict(df_cat, observed, index, data): # GH 24880 @@ -1435,7 +1435,7 @@ def test_series_groupby_categorical_aggregation_getitem(): @pytest.mark.parametrize( "func, expected_values", - [(pd.Series.nunique, [1, 1, 2]), (pd.Series.count, [1, 2, 2])], + [(pd.Series.nunique, [1, 1, 2]), (pd.Series.count, [1, 2, 2])] ) def test_groupby_agg_categorical_columns(func, expected_values): # 31256 diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index c743058c988b40..e598f1466541eb 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -1634,7 +1634,7 @@ def test_transform_doesnt_clobber_ints(): @pytest.mark.parametrize( "sort_column", - ["ints", "floats", "strings", ["ints", "floats"], ["ints", "strings"]], + ["ints", "floats", "strings", ["ints", "floats"], ["ints", "strings"]] ) @pytest.mark.parametrize( "group_column", ["int_groups", "string_groups", ["int_groups", "string_groups"]] @@ -1925,7 +1925,7 @@ def test_groupby_axis_1(group_name): ] }, ), - ], + ] ) def test_shift_bfill_ffill_tz(tz_naive_fixture, op, expected): # GH19995, GH27992: Check that timezone does not drop in shift, bfill, and ffill @@ -2042,7 +2042,7 @@ def test_groupby_list_level(): [ (5, "{0: [0], 1: [1], 2: [2], 3: [3], 4: [4]}"), (4, "{0: [0], 1: [1], 2: [2], 3: [3], ...}"), - ], + ] ) def test_groups_repr_truncates(max_seq_items, expected): # GH 1135 @@ -2097,7 +2097,7 @@ def test_group_on_two_row_multiindex_returns_one_tuple_key(): (Series, "squeeze", True), (Series, "observed", True), (Series, "dropna", False), - ], + ] ) @pytest.mark.filterwarnings( "ignore:The `squeeze` parameter is deprecated:FutureWarning" diff --git a/pandas/tests/groupby/test_groupby_dropna.py b/pandas/tests/groupby/test_groupby_dropna.py index adf62c47235261..640fca4c5253b2 100644 --- a/pandas/tests/groupby/test_groupby_dropna.py +++ b/pandas/tests/groupby/test_groupby_dropna.py @@ -22,7 +22,7 @@ "e": [13.0, 12.0, 1.0], }, ), - ], + ] ) def test_groupby_dropna_multi_index_dataframe_nan_in_one_group( dropna, tuples, outputs, nulls_fixture @@ -65,7 +65,7 @@ def test_groupby_dropna_multi_index_dataframe_nan_in_one_group( "e": [12.0, 13.0, 1.0, 1.0], }, ), - ], + ] ) def test_groupby_dropna_multi_index_dataframe_nan_in_two_groups( dropna, tuples, outputs, nulls_fixture, nulls_fixture2 @@ -105,7 +105,7 @@ def test_groupby_dropna_multi_index_dataframe_nan_in_two_groups( "d": [1.0, 13.0, 12.0], }, ), - ], + ] ) def test_groupby_dropna_normal_index_dataframe(dropna, idx, outputs): # GH 3729 @@ -132,7 +132,7 @@ def test_groupby_dropna_normal_index_dataframe(dropna, idx, outputs): ["a", "a", "b", np.nan], pd.Series([3, 3, 3], index=["a", "b", np.nan]), ), - ], + ] ) def test_groupby_dropna_series_level(dropna, idx, expected): ser = pd.Series([1, 2, 3, 3], index=idx) @@ -149,7 +149,7 @@ def test_groupby_dropna_series_level(dropna, idx, expected): False, pd.Series([210.0, 350.0, 20.0], index=["a", "b", np.nan], name="Max Speed"), ), - ], + ] ) def test_groupby_dropna_series_by(dropna, expected): ser = pd.Series( @@ -176,7 +176,7 @@ def test_groupby_dropna_series_by(dropna, expected): pd.DataFrame({"B": [2, 2, 1, 1]}), pd.Series(data=[2, 2, 1, 1], name="B"), ), - ], + ] ) def test_slice_groupby_then_transform(dropna, df_expected, s_expected): # GH35014 @@ -213,7 +213,7 @@ def test_slice_groupby_then_transform(dropna, df_expected, s_expected): "e": [1.0, 12.0, 1.0], }, ), - ], + ] ) def test_groupby_dropna_multi_index_dataframe_agg(dropna, tuples, outputs): # GH 3729 @@ -244,11 +244,9 @@ def test_groupby_dropna_multi_index_dataframe_agg(dropna, tuples, outputs): (pd.Timestamp("2020-01-01"), pd.Timestamp("2020-02-01")), (pd.Timedelta("-2 days"), pd.Timedelta("-1 days")), (pd.Period("2020-01-01"), pd.Period("2020-02-01")), - ], -) -@pytest.mark.parametrize( - "dropna, values", [(True, [12, 3]), (False, [12, 3, 6],)], + ] ) +@pytest.mark.parametrize("dropna, values", [(True, [12, 3]), (False, [12, 3, 6],)]) def test_groupby_dropna_datetime_like_data( dropna, values, datetime1, datetime2, unique_nulls_fixture, unique_nulls_fixture2 ): diff --git a/pandas/tests/groupby/test_groupby_subclass.py b/pandas/tests/groupby/test_groupby_subclass.py index 7271911c5f80ff..adcc6aefbe3079 100644 --- a/pandas/tests/groupby/test_groupby_subclass.py +++ b/pandas/tests/groupby/test_groupby_subclass.py @@ -12,7 +12,7 @@ [ tm.SubclassedDataFrame({"A": np.arange(0, 10)}), tm.SubclassedSeries(np.arange(0, 10), name="A"), - ], + ] ) @pytest.mark.filterwarnings("ignore:tshift is deprecated:FutureWarning") def test_groupby_preserves_subclass(obj, groupby_func): @@ -51,9 +51,7 @@ def test_groupby_preserves_subclass(obj, groupby_func): tm.assert_series_equal(result1, result2) -@pytest.mark.parametrize( - "obj", [DataFrame, tm.SubclassedDataFrame], -) +@pytest.mark.parametrize("obj", [DataFrame, tm.SubclassedDataFrame]) def test_groupby_resample_preserves_subclass(obj): # GH28330 -- preserve subclass through groupby.resample() diff --git a/pandas/tests/groupby/test_size.py b/pandas/tests/groupby/test_size.py index 9cff8b966dad02..4fb383b5b535a6 100644 --- a/pandas/tests/groupby/test_size.py +++ b/pandas/tests/groupby/test_size.py @@ -53,7 +53,8 @@ def test_size_on_categorical(as_index): result = df.groupby(["A", "B"], as_index=as_index).size() expected = DataFrame( - [[1, 1, 1], [1, 2, 0], [2, 1, 0], [2, 2, 1]], columns=["A", "B", "size"], + [[1, 1, 1], [1, 2, 0], [2, 1, 0], [2, 2, 1]], + columns=["A", "B", "size"] ) expected["A"] = expected["A"].astype("category") if as_index: diff --git a/pandas/tests/groupby/test_timegrouper.py b/pandas/tests/groupby/test_timegrouper.py index 84fd7a1bdfb05f..4ccbc6a65fd886 100644 --- a/pandas/tests/groupby/test_timegrouper.py +++ b/pandas/tests/groupby/test_timegrouper.py @@ -780,6 +780,6 @@ def test_grouper_period_index(self): result = period_series.groupby(period_series.index.month).sum() expected = pd.Series( - range(0, periods), index=Index(range(1, periods + 1), name=index.name), + range(0, periods), index=Index(range(1, periods + 1), name=index.name) ) tm.assert_series_equal(result, expected)