Skip to content

Commit 8409dc2

Browse files
committed
Fixed test, added whatsnew
1 parent 85e8b06 commit 8409dc2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

doc/source/whatsnew/v1.2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Plotting
132132
Groupby/resample/rolling
133133
^^^^^^^^^^^^^^^^^^^^^^^^
134134

135-
-
135+
- Bug when subsetting columns on a :class:`~pandas.core.groupby.DataFrameGroupBy` (e.g. ``df.groupby('a')['b'])``) would reset the attributes ``axis``, ``dropna``, ``group_keys``, ``level``, ``mutated``, ``sort``, and ``squeeze`` to their default values. (:issue:`9959`)
136136
-
137137

138138

pandas/tests/groupby/test_groupby.py

+2
Original file line numberDiff line numberDiff line change
@@ -2070,11 +2070,13 @@ def test_groups_repr_truncates(max_seq_items, expected):
20702070
("dropna", False),
20712071
],
20722072
)
2073+
@pytest.mark.filterwarnings("ignore:The `squeeze` parameter is deprecated:FutureWarning")
20732074
def test_subsetting_columns_keeps_attrs(attr, value):
20742075
# GH 9959 - When subsetting columns, don't drop attributes
20752076
df = pd.DataFrame({"a": [1], "b": [2], "c": [3]})
20762077
if attr != "axis":
20772078
df = df.set_index("a")
2079+
20782080
expected = df.groupby("a", **{attr: value})
20792081

20802082
result = expected[["b"]]

0 commit comments

Comments
 (0)