From 60e563f689aff107e916e2b05e812cfdc1affa47 Mon Sep 17 00:00:00 2001 From: aflah02 <72096386+aflah02@users.noreply.github.com> Date: Thu, 17 Dec 2020 10:51:53 +0530 Subject: [PATCH 1/5] Update generic.py Added Documentation mentioning that DataFrame.last() needs the index to be sorted to deliver the expected results --- pandas/core/generic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index f9aa5ca9e8ea9..7a845dcf67597 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8441,6 +8441,8 @@ def last(self: FrameOrSeries, offset) -> FrameOrSeries: When having a DataFrame with dates as index, this function can select the last few rows based on a date offset. + + Note that for the last() method to work, the DatetimeIndex must be sorted otherwise it will not work as intended. Parameters ---------- From 9f2cb0499342f5f1b4f29f5eca2f62cd047b15c0 Mon Sep 17 00:00:00 2001 From: aflah02 <72096386+aflah02@users.noreply.github.com> Date: Thu, 17 Dec 2020 11:18:01 +0530 Subject: [PATCH 2/5] Update generic.py Fixed PEP8 Issues --- pandas/core/generic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 7a845dcf67597..bcfefbe360685 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8441,8 +8441,9 @@ def last(self: FrameOrSeries, offset) -> FrameOrSeries: When having a DataFrame with dates as index, this function can select the last few rows based on a date offset. - - Note that for the last() method to work, the DatetimeIndex must be sorted otherwise it will not work as intended. + + Note that for the last() method to work, the DatetimeIndex + must be sorted otherwise it will not work as intended. Parameters ---------- From 4c2ba8d9578672f27e5c633df9b254c65e1a9f16 Mon Sep 17 00:00:00 2001 From: aflah02 <72096386+aflah02@users.noreply.github.com> Date: Thu, 17 Dec 2020 11:28:31 +0530 Subject: [PATCH 3/5] Update generic.py Fixed PEP 8 Issues --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index bcfefbe360685..1c9e8453c5276 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8442,7 +8442,7 @@ def last(self: FrameOrSeries, offset) -> FrameOrSeries: When having a DataFrame with dates as index, this function can select the last few rows based on a date offset. - Note that for the last() method to work, the DatetimeIndex + Note that for the last() method to work, the DatetimeIndex must be sorted otherwise it will not work as intended. Parameters From a12a2dab7c31cc8e865b59c7e0c45bcf47a725da Mon Sep 17 00:00:00 2001 From: aflah02 <72096386+aflah02@users.noreply.github.com> Date: Thu, 17 Dec 2020 13:47:23 +0530 Subject: [PATCH 4/5] Update generic.py As per recommendation changed the description for DataFrame.last() making it more concise --- pandas/core/generic.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 1c9e8453c5276..015a90200ea3b 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8439,11 +8439,8 @@ def last(self: FrameOrSeries, offset) -> FrameOrSeries: """ Select final periods of time series data based on a date offset. - When having a DataFrame with dates as index, this function can - select the last few rows based on a date offset. - - Note that for the last() method to work, the DatetimeIndex - must be sorted otherwise it will not work as intended. + For a DataFrame with a sorted DatetimeIndex, this function + selects the last few rows based on a date offset. Parameters ---------- From 67a777166f46cc25b2d2f9d91625045d31dc6ffe Mon Sep 17 00:00:00 2001 From: aflah02 <72096386+aflah02@users.noreply.github.com> Date: Thu, 17 Dec 2020 13:51:43 +0530 Subject: [PATCH 5/5] Update generic.py Removed trailing whitespace to fix PEP 8 Issues --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 015a90200ea3b..9b0c3caa0b407 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8439,7 +8439,7 @@ def last(self: FrameOrSeries, offset) -> FrameOrSeries: """ Select final periods of time series data based on a date offset. - For a DataFrame with a sorted DatetimeIndex, this function + For a DataFrame with a sorted DatetimeIndex, this function selects the last few rows based on a date offset. Parameters