@@ -260,7 +260,7 @@ class providing the base-class of operations.
260
260
each group together into a Series, including setting the index as
261
261
appropriate:
262
262
263
- >>> g1[['B', 'C']] .apply(lambda x: x.C.max() - x.B.min())
263
+ >>> g1.apply(lambda x: x.C.max() - x.B.min())
264
264
A
265
265
a 5
266
266
b 2
@@ -1500,16 +1500,6 @@ def f(g):
1500
1500
with option_context ("mode.chained_assignment" , None ):
1501
1501
try :
1502
1502
result = self ._python_apply_general (f , self ._selected_obj )
1503
- if (
1504
- not isinstance (self .obj , Series )
1505
- and self ._selection is None
1506
- and self ._selected_obj .shape != self ._obj_with_exclusions .shape
1507
- ):
1508
- warnings .warn (
1509
- message = _apply_groupings_depr .format (type (self ).__name__ ),
1510
- category = FutureWarning ,
1511
- stacklevel = find_stack_level (),
1512
- )
1513
1503
except TypeError :
1514
1504
# gh-20949
1515
1505
# try again, with .apply acting as a filtering
@@ -2671,55 +2661,55 @@ def resample(self, rule, *args, **kwargs):
2671
2661
Downsample the DataFrame into 3 minute bins and sum the values of
2672
2662
the timestamps falling into a bin.
2673
2663
2674
- >>> df.groupby('a')[['b']] .resample('3T').sum()
2675
- b
2664
+ >>> df.groupby('a').resample('3T').sum()
2665
+ a b
2676
2666
a
2677
- 0 2000-01-01 00:00:00 2
2678
- 2000-01-01 00:03:00 1
2679
- 5 2000-01-01 00:00:00 1
2667
+ 0 2000-01-01 00:00:00 0 2
2668
+ 2000-01-01 00:03:00 0 1
2669
+ 5 2000-01-01 00:00:00 5 1
2680
2670
2681
2671
Upsample the series into 30 second bins.
2682
2672
2683
- >>> df.groupby('a')[['b']] .resample('30S').sum()
2684
- b
2673
+ >>> df.groupby('a').resample('30S').sum()
2674
+ a b
2685
2675
a
2686
- 0 2000-01-01 00:00:00 1
2687
- 2000-01-01 00:00:30 0
2688
- 2000-01-01 00:01:00 1
2689
- 2000-01-01 00:01:30 0
2690
- 2000-01-01 00:02:00 0
2691
- 2000-01-01 00:02:30 0
2692
- 2000-01-01 00:03:00 1
2693
- 5 2000-01-01 00:02:00 1
2676
+ 0 2000-01-01 00:00:00 0 1
2677
+ 2000-01-01 00:00:30 0 0
2678
+ 2000-01-01 00:01:00 0 1
2679
+ 2000-01-01 00:01:30 0 0
2680
+ 2000-01-01 00:02:00 0 0
2681
+ 2000-01-01 00:02:30 0 0
2682
+ 2000-01-01 00:03:00 0 1
2683
+ 5 2000-01-01 00:02:00 5 1
2694
2684
2695
2685
Resample by month. Values are assigned to the month of the period.
2696
2686
2697
- >>> df.groupby('a')[['b']] .resample('M').sum()
2698
- b
2687
+ >>> df.groupby('a').resample('M').sum()
2688
+ a b
2699
2689
a
2700
- 0 2000-01-31 3
2701
- 5 2000-01-31 1
2690
+ 0 2000-01-31 0 3
2691
+ 5 2000-01-31 5 1
2702
2692
2703
2693
Downsample the series into 3 minute bins as above, but close the right
2704
2694
side of the bin interval.
2705
2695
2706
- >>> df.groupby('a')[['b']] .resample('3T', closed='right').sum()
2707
- b
2696
+ >>> df.groupby('a').resample('3T', closed='right').sum()
2697
+ a b
2708
2698
a
2709
- 0 1999-12-31 23:57:00 1
2710
- 2000-01-01 00:00:00 2
2711
- 5 2000-01-01 00:00:00 1
2699
+ 0 1999-12-31 23:57:00 0 1
2700
+ 2000-01-01 00:00:00 0 2
2701
+ 5 2000-01-01 00:00:00 5 1
2712
2702
2713
2703
Downsample the series into 3 minute bins and close the right side of
2714
2704
the bin interval, but label each bin using the right edge instead of
2715
2705
the left.
2716
2706
2717
- >>> df.groupby('a')[['b']] .resample('3T', closed='right', label='right').sum()
2718
- b
2707
+ >>> df.groupby('a').resample('3T', closed='right', label='right').sum()
2708
+ a b
2719
2709
a
2720
- 0 2000-01-01 00:00:00 1
2721
- 2000-01-01 00:03:00 2
2722
- 5 2000-01-01 00:03:00 1
2710
+ 0 2000-01-01 00:00:00 0 1
2711
+ 2000-01-01 00:03:00 0 2
2712
+ 5 2000-01-01 00:03:00 5 1
2723
2713
"""
2724
2714
from pandas .core .resample import get_resampler_for_grouping
2725
2715
@@ -4343,13 +4333,3 @@ def _insert_quantile_level(idx: Index, qs: npt.NDArray[np.float64]) -> MultiInde
4343
4333
else :
4344
4334
mi = MultiIndex .from_product ([idx , qs ])
4345
4335
return mi
4346
-
4347
-
4348
- # GH#7155
4349
- _apply_groupings_depr = (
4350
- "{}.apply operated on the grouping columns. This behavior is deprecated, "
4351
- "and in a future version of pandas the grouping columns will be excluded "
4352
- "from the operation. Select the columns to operate on after groupby to"
4353
- "either explicitly include or exclude the groupings and silence "
4354
- "this warning."
4355
- )
0 commit comments