From bbd9ec3a9a7a693fbffcbe6c87b43971252f3442 Mon Sep 17 00:00:00 2001 From: sunwooma Date: Sun, 21 Apr 2024 16:13:44 -0400 Subject: [PATCH 1/6] First commit --- pandas/core/arrays/datetimes.py | 5 ++--- pandas/core/frame.py | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 7704c99141fc2..ef2b17024e620 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1628,9 +1628,8 @@ def isocalendar(self) -> DataFrame: See Also -------- - DatetimeIndex.day: The day of the datetime. - DatetimeIndex.minute: The minutes of the datetime. - DatetimeIndex.second: The seconds of the datetime. + Series.dt.minute : Minutes of the datetime. + Series.dt.second : Seconds of the datetime. Examples -------- diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 0185ca8241617..9d935f3c9f9f5 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -21,6 +21,7 @@ Sequence, ) import functools +import pandas as pd from inspect import signature from io import StringIO import itertools @@ -2865,7 +2866,8 @@ def to_parquet( Returns ------- - bytes if no path argument is provided else None + bytes or None + If no `path` argument is provided, returns the bytes representation of the DataFrame written in the Parquet format. If a `path` argument is provided, returns None. See Also -------- @@ -8985,6 +8987,9 @@ def groupby( if level is None and by is None: raise TypeError("You have to supply one of 'by' and 'level'") + if not as_index and isinstance(by, pd.Series) and by.name in self.columns: + raise ValueError(f"cannot insert {by.name}, already exists") + return DataFrameGroupBy( obj=self, keys=by, From d1a68f6a39d6213d083f9f25caf83f88d24db2d8 Mon Sep 17 00:00:00 2001 From: sunwooma Date: Mon, 22 Apr 2024 13:40:49 -0400 Subject: [PATCH 2/6] commit for docstrings --- pandas/core/frame.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 9d935f3c9f9f5..3b6a5284a25ab 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8987,9 +8987,6 @@ def groupby( if level is None and by is None: raise TypeError("You have to supply one of 'by' and 'level'") - if not as_index and isinstance(by, pd.Series) and by.name in self.columns: - raise ValueError(f"cannot insert {by.name}, already exists") - return DataFrameGroupBy( obj=self, keys=by, From addc1dae58e77217a66ae92660a58463a6146aa4 Mon Sep 17 00:00:00 2001 From: sunwooma Date: Mon, 22 Apr 2024 13:55:23 -0400 Subject: [PATCH 3/6] returning bug fix --- pandas/core/frame.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3b6a5284a25ab..6950c7378f23f 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8986,6 +8986,10 @@ def groupby( if level is None and by is None: raise TypeError("You have to supply one of 'by' and 'level'") + + if not as_index and isinstance(by, Series) and by.name in self.columns: + raise ValueError(f"cannot insert {by.name}, already exists") + return DataFrameGroupBy( obj=self, From 6e37e52c5df5591313f9815ab44d43393d2a136f Mon Sep 17 00:00:00 2001 From: sunwooma Date: Mon, 22 Apr 2024 14:03:22 -0400 Subject: [PATCH 4/6] reverting docstring fixes, making separate pull request --- pandas/core/arrays/datetimes.py | 5 +++-- pandas/core/frame.py | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index ef2b17024e620..7704c99141fc2 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1628,8 +1628,9 @@ def isocalendar(self) -> DataFrame: See Also -------- - Series.dt.minute : Minutes of the datetime. - Series.dt.second : Seconds of the datetime. + DatetimeIndex.day: The day of the datetime. + DatetimeIndex.minute: The minutes of the datetime. + DatetimeIndex.second: The seconds of the datetime. Examples -------- diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 6950c7378f23f..f1b2e2dc565de 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2866,8 +2866,7 @@ def to_parquet( Returns ------- - bytes or None - If no `path` argument is provided, returns the bytes representation of the DataFrame written in the Parquet format. If a `path` argument is provided, returns None. + bytes if no path argument is provided else None See Also -------- From b612234c68f7848dc1fbe31367987051f54c1b69 Mon Sep 17 00:00:00 2001 From: sunwooma Date: Mon, 22 Apr 2024 14:05:45 -0400 Subject: [PATCH 5/6] removed unnecessary library import --- pandas/core/frame.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f1b2e2dc565de..3f325bef64eb8 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -21,7 +21,6 @@ Sequence, ) import functools -import pandas as pd from inspect import signature from io import StringIO import itertools @@ -2866,7 +2865,6 @@ def to_parquet( Returns ------- - bytes if no path argument is provided else None See Also -------- From 49850eae074664f53d2d4157a3e6391756330239 Mon Sep 17 00:00:00 2001 From: sunwooma Date: Mon, 22 Apr 2024 14:07:25 -0400 Subject: [PATCH 6/6] finalization --- pandas/core/frame.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3f325bef64eb8..2d07e67654163 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2865,7 +2865,8 @@ def to_parquet( Returns ------- - + bytes if no path argument is provided else None + See Also -------- read_parquet : Read a parquet file.