Skip to content

Commit 1ca73fd

Browse files
committed
change _selected_obj according to self.mutated
1 parent 9acbe37 commit 1ca73fd

File tree

5 files changed

+6
-15
lines changed

5 files changed

+6
-15
lines changed

pandas/core/frame.py

-1
Original file line numberDiff line numberDiff line change
@@ -7732,7 +7732,6 @@ def count(self, axis=0, level=None, numeric_only=False):
77327732
Lewis 1
77337733
Myla 1
77347734
"""
7735-
breakpoint()
77367735
axis = self._get_axis_number(axis)
77377736
if level is not None:
77387737
return self._count_level(level, axis=axis, numeric_only=numeric_only)

pandas/core/groupby/groupby.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ class providing the base-class of operations.
66
(defined in pandas.core.groupby.generic)
77
expose these user-facing objects to provide specific functionality.
88
"""
9-
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
109

1110
from contextlib import contextmanager
1211
import datetime
@@ -409,6 +408,7 @@ def __init__(
409408
observed=observed,
410409
mutated=self.mutated,
411410
)
411+
412412
self.obj = obj
413413
self.axis = obj._get_axis_number(axis)
414414
self.grouper = grouper
@@ -508,8 +508,7 @@ def _get_index(self, name):
508508
@cache_readonly
509509
def _selected_obj(self):
510510
# Note: _selected_obj is always just `self.obj` for SeriesGroupBy
511-
breakpoint()
512-
if self.as_index:
511+
if self.mutated:
513512
obj = self._obj_with_exclusions
514513
else:
515514
obj = self.obj

pandas/core/window/rolling.py

+3
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ class _Rolling_and_Expanding(_Rolling):
11731173
)
11741174

11751175
def count(self):
1176+
11761177
blocks, obj = self._create_blocks()
11771178
results = []
11781179
for b in blocks:
@@ -1186,6 +1187,7 @@ def count(self):
11861187
closed=self.closed,
11871188
).sum()
11881189
results.append(result)
1190+
11891191
return self._wrap_results(results, blocks, obj)
11901192

11911193
_shared_docs["apply"] = dedent(
@@ -1951,6 +1953,7 @@ def aggregate(self, func, *args, **kwargs):
19511953
@Substitution(name="rolling")
19521954
@Appender(_shared_docs["count"])
19531955
def count(self):
1956+
19541957
# different impl for freq counting
19551958
if self.is_freq_type:
19561959
window_func = self._get_roll_func("roll_count")

pandas/tests/groupby/test_apply.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ def f(group):
405405

406406
expected = df.copy()
407407
expected["v2"] = np.tile([0.0, 0.5, 1], 2)
408+
408409
tm.assert_frame_equal(result, expected)
409410

410411

@@ -826,7 +827,6 @@ def test_apply_index_has_complex_internals(index):
826827
# GH 31248
827828
df = DataFrame({"group": [1, 1, 2], "value": [0, 1, 0]}, index=index)
828829
result = df.groupby("group").apply(lambda x: x)
829-
breakpoint()
830830
tm.assert_frame_equal(result, df)
831831

832832

pandas/tests/window/test_rolling.py

-10
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,3 @@ def test_by_column_not_in_values():
477477
result = r.sum()
478478
assert "A" not in result.columns
479479
tm.assert_frame_equal(g.obj, original_obj) # check for side-effects
480-
481-
# g = df.groupby("A")
482-
# original_obj = g.obj.copy(deep=True)
483-
# r = g.rolling(4)
484-
# def cust(x):
485-
# breakpoint()
486-
# return getattr(x.rolling(4), 'sum')()
487-
# result = r.apply(cust)
488-
# assert "A" not in result.columns
489-
# tm.assert_frame_equal(g.obj, original_obj) # check for side-effects

0 commit comments

Comments
 (0)