From a20e325054230895142a89e67846310049408a04 Mon Sep 17 00:00:00 2001 From: "[u6598849]" Date: Mon, 24 Oct 2022 10:00:21 +0800 Subject: [PATCH 1/6] Updated the shape function's documentation. --- pandas/core/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/core/base.py b/pandas/core/base.py index 927a3ed6a601c..8b166657301bb 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -319,6 +319,17 @@ def transpose(self: _T, *args, **kwargs) -> _T: def shape(self) -> Shape: """ Return a tuple of the shape of the underlying data. + + Returns + -------- + tuple + Shape of the Series. + + Examples + -------- + >>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey']) + 5 + """ return self._values.shape From 5ed2a9ad4c741b69e1f744a92d26853df432f862 Mon Sep 17 00:00:00 2001 From: "[u6598849]" Date: Mon, 24 Oct 2022 11:46:35 +0800 Subject: [PATCH 2/6] Finished docstring updates for Series.shape and Series.size. --- pandas/core/base.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 8b166657301bb..5811f51903796 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -324,12 +324,16 @@ def shape(self) -> Shape: -------- tuple Shape of the Series. + + See Also + -------- + Series.size : Returns the size of the Series as an int. Examples -------- >>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey']) - 5 - + >>> s.shape() + (5,) """ return self._values.shape @@ -373,6 +377,21 @@ def nbytes(self) -> int: def size(self) -> int: """ Return the number of elements in the underlying data. + + Returns + -------- + int + Size of the array. + + See Also + -------- + Series.shape : Returns the shape of the Series as a tuple. + + Examples + -------- + >>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey']) + >>> s.size() + 5 """ return len(self._values) From 3e9219971cd57519ebf1db61a66556dcc1c0f419 Mon Sep 17 00:00:00 2001 From: "[u6598849]" Date: Mon, 24 Oct 2022 22:56:02 +0800 Subject: [PATCH 3/6] Worked on and adjusted some examples. --- pandas/core/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 5811f51903796..966ba0dc5e2d1 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -332,7 +332,7 @@ def shape(self) -> Shape: Examples -------- >>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey']) - >>> s.shape() + >>> s.shape (5,) """ return self._values.shape @@ -390,7 +390,7 @@ def size(self) -> int: Examples -------- >>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey']) - >>> s.size() + >>> s.size 5 """ return len(self._values) From 910c76e02465fc0b8464835f7a2abc30c7384335 Mon Sep 17 00:00:00 2001 From: "[u6598849]" Date: Wed, 26 Oct 2022 13:01:36 +0800 Subject: [PATCH 4/6] Finished documentation for dtype; dtypes --- pandas/core/series.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index f0327dfd39134..3dc0e81f25159 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -606,6 +606,21 @@ def _set_axis(self, axis: AxisInt, labels: AnyArrayLike | list) -> None: def dtype(self) -> DtypeObj: """ Return the dtype object of the underlying data. + + Returns + -------- + dtype + dtype of the underlying data. + + See Also + -------- + Series.dtypes : Returns the dtype object of the underlying data. + + Examples + -------- + >> s = pd.Series([0, 1, 2, 3, 4]) + >> s.dtype + dtype('int64') """ return self._mgr.dtype @@ -613,6 +628,22 @@ def dtype(self) -> DtypeObj: def dtypes(self) -> DtypeObj: """ Return the dtype object of the underlying data. + + Returns + -------- + dtype + dtype of the underlying data. + + See Also + -------- + Series.dtype : Returns the dtype object of the underlying data, normally used for + DataFrames. + + Examples + -------- + >> s = pd.Series([0, 1, 2, 3, 4]) + >> s.dtypes + dtype('int64') """ # DataFrame compatibility return self.dtype From a47b597a305a0a96f4d9627c818c3dc710e80a6c Mon Sep 17 00:00:00 2001 From: "[u6598849]" Date: Wed, 26 Oct 2022 13:05:55 +0800 Subject: [PATCH 5/6] Finished hasnans documentation. --- pandas/core/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/core/base.py b/pandas/core/base.py index 966ba0dc5e2d1..6ed10229cfa2b 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -803,6 +803,17 @@ def hasnans(self) -> bool: Return True if there are any NaNs. Enables various performance speedups. + + Returns + -------- + bool + Whether the Series contains a NaN. + + Examples + -------- + >> s = pd.Series([0, 1, np.nan, 3, 4]) + >> s.hasnans + True """ # error: Item "bool" of "Union[bool, ndarray[Any, dtype[bool_]], NDFrame]" # has no attribute "any" From 10b2a0b10c6c9f206f433e8313a180e4c45c0056 Mon Sep 17 00:00:00 2001 From: "[u6598849]" Date: Fri, 28 Oct 2022 16:15:41 +0000 Subject: [PATCH 6/6] Running pre-commit after fixing a failed test. --- pandas/core/base.py | 6 +++--- pandas/core/series.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index c39e0d029de94..be9e65d40cd8b 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -326,7 +326,7 @@ def shape(self) -> Shape: See Also -------- Series.size : Returns the size of the Series as an int. - + Examples -------- >>> s = pd.Series(['Cat', 'Dog', 'Cow', 'Zebra', 'Monkey']) @@ -380,7 +380,7 @@ def size(self) -> int: -------- int Size of the array. - + See Also -------- Series.shape : Returns the shape of the Series as a tuple. @@ -806,7 +806,7 @@ def hasnans(self) -> bool: -------- bool Whether the Series contains a NaN. - + Examples -------- >> s = pd.Series([0, 1, np.nan, 3, 4]) diff --git a/pandas/core/series.py b/pandas/core/series.py index 0418d678b8487..0d05384bc10b6 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -578,7 +578,7 @@ def dtype(self) -> DtypeObj: -------- dtype dtype of the underlying data. - + See Also -------- Series.dtypes : Returns the dtype object of the underlying data. @@ -600,17 +600,17 @@ def dtypes(self) -> DtypeObj: -------- dtype dtype of the underlying data. - + See Also -------- - Series.dtype : Returns the dtype object of the underlying data, normally used for - DataFrames. + Series.dtype : Returns the dtype object of the underlying data, normally used + for DataFrames. Examples -------- >> s = pd.Series([0, 1, 2, 3, 4]) >> s.dtypes - dtype('int64') + dtype('int64') """ # DataFrame compatibility return self.dtype