Skip to content

Commit

Permalink
CLN remove unnecessary trailing commas in groupby tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xcz011 committed Sep 2, 2020
1 parent 0bc407a commit 9544213
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pandas/tests/groupby/aggregate/test_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/groupby/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/groupby/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1102,7 +1102,7 @@ def test_groupby_multiindex_categorical_datetime():
}
),
),
],
]
)
def test_groupby_agg_observed_true_single_column(as_index, expected):
# GH-23970
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
20 changes: 9 additions & 11 deletions pandas/tests/groupby/test_groupby_dropna.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
):
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/groupby/test_groupby_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/groupby/test_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_timegrouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 9544213

Please sign in to comment.