From b910c05974a60ba31593b9524b9746092a4b33c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Thu, 29 Jun 2023 14:37:49 +0200 Subject: [PATCH] Changed M to MS in examples --- pandas/core/groupby/groupby.py | 18 +++++++++--------- pandas/core/resample.py | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 30f5f21f03658..498e66ad00da9 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -764,8 +764,8 @@ def groups(self) -> dict[Hashable, np.ndarray]: 2023-02-01 3 2023-02-15 4 dtype: int64 - >>> ser.resample('M').groups - {Timestamp('2023-01-31 00:00:00'): 2, Timestamp('2023-02-28 00:00:00'): 4} + >>> ser.resample('MS').groups + {Timestamp('2023-01-01 00:00:00'): 2, Timestamp('2023-02-01 00:00:00'): 4} """ return self.grouper.groups @@ -818,9 +818,9 @@ def indices(self) -> dict[Hashable, npt.NDArray[np.intp]]: 2023-02-01 3 2023-02-15 4 dtype: int64 - >>> ser.resample('M').indices - defaultdict(, {Timestamp('2023-01-31 00:00:00'): [0, 1], - Timestamp('2023-02-28 00:00:00'): [2, 3]}) + >>> ser.resample('MS').indices + defaultdict(, {Timestamp('2023-01-01 00:00:00'): [0, 1], + Timestamp('2023-02-01 00:00:00'): [2, 3]}) """ return self.grouper.indices @@ -1003,7 +1003,7 @@ def get_group(self, name, obj=None) -> DataFrame | Series: 2023-02-01 3 2023-02-15 4 dtype: int64 - >>> ser.resample('M').get_group('2023-01-31') + >>> ser.resample('MS').get_group('2023-01-01') 2023-01-01 1 2023-01-15 2 dtype: int64 @@ -1085,13 +1085,13 @@ def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]: 2023-02-01 3 2023-02-15 4 dtype: int64 - >>> for x, y in ser.resample('M'): + >>> for x, y in ser.resample('MS'): ... print(f'{x}\\n{y}\\n') - 2023-01-31 00:00:00 + 2023-01-01 00:00:00 2023-01-01 1 2023-01-15 2 dtype: int64 - 2023-02-28 00:00:00 + 2023-02-01 00:00:00 2023-02-01 3 2023-02-15 4 dtype: int64 diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 9c8a9a0d63a14..4c7cfc453c8a7 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -519,10 +519,10 @@ def ffill(self, limit: int | None = None): Example for ``ffill`` with downsampling (we have fewer dates after resampling): - >>> ser.resample('M').ffill() - 2023-01-31 2 - 2023-02-28 4 - Freq: M, dtype: int64 + >>> ser.resample('MS').ffill() + 2023-01-01 1 + 2023-02-01 3 + Freq: MS, dtype: int64 Example for ``ffill`` with upsampling (fill the new dates with the previous value):