@@ -753,6 +753,19 @@ def groups(self) -> dict[Hashable, np.ndarray]:
753
753
2 7 8 9
754
754
>>> df.groupby(by=["a"]).groups
755
755
{1: [0, 1], 7: [2]}
756
+
757
+ For Resampler:
758
+
759
+ >>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
760
+ ... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
761
+ >>> ser
762
+ 2023-01-01 1
763
+ 2023-01-15 2
764
+ 2023-02-01 3
765
+ 2023-02-15 4
766
+ dtype: int64
767
+ >>> ser.resample('M').groups
768
+ {Timestamp('2023-01-31 00:00:00'): 2, Timestamp('2023-02-28 00:00:00'): 4}
756
769
"""
757
770
return self .grouper .groups
758
771
@@ -794,6 +807,20 @@ def indices(self) -> dict[Hashable, npt.NDArray[np.intp]]:
794
807
eagle 7 8 9
795
808
>>> df.groupby(by=["a"]).indices
796
809
{1: array([0, 1]), 7: array([2])}
810
+
811
+ For Resampler:
812
+
813
+ >>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
814
+ ... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
815
+ >>> ser
816
+ 2023-01-01 1
817
+ 2023-01-15 2
818
+ 2023-02-01 3
819
+ 2023-02-15 4
820
+ dtype: int64
821
+ >>> ser.resample('M').indices
822
+ defaultdict(<class 'list'>, {Timestamp('2023-01-31 00:00:00'): [0, 1],
823
+ Timestamp('2023-02-28 00:00:00'): [2, 3]})
797
824
"""
798
825
return self .grouper .indices
799
826
@@ -965,6 +992,21 @@ def get_group(self, name, obj=None) -> DataFrame | Series:
965
992
a b c
966
993
owl 1 2 3
967
994
toucan 1 5 6
995
+
996
+ For Resampler:
997
+
998
+ >>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
999
+ ... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
1000
+ >>> ser
1001
+ 2023-01-01 1
1002
+ 2023-01-15 2
1003
+ 2023-02-01 3
1004
+ 2023-02-15 4
1005
+ dtype: int64
1006
+ >>> ser.resample('M').get_group('2023-01-31')
1007
+ 2023-01-01 1
1008
+ 2023-01-15 2
1009
+ dtype: int64
968
1010
"""
969
1011
inds = self ._get_index (name )
970
1012
if not len (inds ):
@@ -1032,6 +1074,27 @@ def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]:
1032
1074
(7,)
1033
1075
a b c
1034
1076
2 7 8 9
1077
+
1078
+ For Resampler:
1079
+
1080
+ >>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
1081
+ ... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
1082
+ >>> ser
1083
+ 2023-01-01 1
1084
+ 2023-01-15 2
1085
+ 2023-02-01 3
1086
+ 2023-02-15 4
1087
+ dtype: int64
1088
+ >>> for x, y in ser.resample('M'):
1089
+ ... print(f'{x}\\ n{y}\\ n')
1090
+ 2023-01-31 00:00:00
1091
+ 2023-01-01 1
1092
+ 2023-01-15 2
1093
+ dtype: int64
1094
+ 2023-02-28 00:00:00
1095
+ 2023-02-01 3
1096
+ 2023-02-15 4
1097
+ dtype: int64
1035
1098
"""
1036
1099
keys = self .keys
1037
1100
level = self .level
0 commit comments