From 318c8dad8ee2c4ab71ff2e5e39adb586e17fdf7d Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Wed, 8 Mar 2023 20:50:59 +0530 Subject: [PATCH 01/26] Update series.py Added the example section. --- pandas/core/series.py | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 95ee3f1af58f1..c2ba00196134f 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5993,6 +5993,54 @@ def mask( index = properties.AxisProperty( axis=0, doc="The index (axis labels) of the Series." + """ + + A one-dimensional ndarray with hashable type axis labels. + + Pandas Series.index attribute is used to get or set the index labels of the given Series object. + The object supports both integer- and label-based indexing and provides a host of methods for performing + operations involving the index. + The labels need not be unique but must be of the hashable type. + + Returns + ------- + index + + Examples + -------- + + **Use the Series.index attribute to set the index label for the given Series object.** + + >>> s = pd.Series(['Kolkata', 'Chicago', 'Toronto', 'Lisbon']) + >>> print(s) + 0 Kolkata + 1 Chicago + 2 Toronto + 3 Lisbon + dtype: object + + The ``Series.index`` attribute will now be used to set the index label for the given object. + + >>> s.index = ['City 1', 'City 2', 'City 3', 'City 4'] + >>> print(s) + City 1 Kolkata + City 2 Chicago + City 3 Toronto + City 4 Lisbon + dtype: object + + As we can see in the output, the ``Series.index`` attribute has successfully set the index labels for the given Series object. + + **We can also assign duplicate or nonunique indexes in Pandas.** + + >>> s.index = ['City 1', 'City 1', 'City 3', 'City 3'] + >>> print(s) + City 1 Kolkata + City 1 Chicago + City 3 Toronto + City 3 Lisbon + dtype: object + """ ) # ---------------------------------------------------------------------- From 8e0951a97f4d2a1eab8d1742dd2cbaa78d8affd2 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:12:33 +0530 Subject: [PATCH 02/26] Update series.py Updated the docstring. --- pandas/core/series.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index c2ba00196134f..cd1496a7c172c 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5994,7 +5994,6 @@ def mask( index = properties.AxisProperty( axis=0, doc="The index (axis labels) of the Series." """ - A one-dimensional ndarray with hashable type axis labels. Pandas Series.index attribute is used to get or set the index labels of the given Series object. From 112928f83990fbe9a4efab98c45ef3ccce0a1a8d Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:26:55 +0530 Subject: [PATCH 03/26] Update series.py Updated the docstring. --- pandas/core/series.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index cd1496a7c172c..1d4fabde3576b 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5996,11 +5996,12 @@ def mask( """ A one-dimensional ndarray with hashable type axis labels. - Pandas Series.index attribute is used to get or set the index labels of the given Series object. - The object supports both integer- and label-based indexing and provides a host of methods for performing - operations involving the index. + Pandas Series.index attribute is used to get or set the index labels + of the given Series object.The object supports both + integer- and label-based indexing and provides a host of methods for + performing operations involving the index. The labels need not be unique but must be of the hashable type. - + Returns ------- index @@ -6008,7 +6009,8 @@ def mask( Examples -------- - **Use the Series.index attribute to set the index label for the given Series object.** + **Use the Series.index attribute to set the index label for + the given Series object.** >>> s = pd.Series(['Kolkata', 'Chicago', 'Toronto', 'Lisbon']) >>> print(s) @@ -6018,7 +6020,8 @@ def mask( 3 Lisbon dtype: object - The ``Series.index`` attribute will now be used to set the index label for the given object. + The ``Series.index`` attribute will now be used to set the index + label for the given object. >>> s.index = ['City 1', 'City 2', 'City 3', 'City 4'] >>> print(s) @@ -6028,7 +6031,8 @@ def mask( City 4 Lisbon dtype: object - As we can see in the output, the ``Series.index`` attribute has successfully set the index labels for the given Series object. + As we can see in the output, the ``Series.index`` attribute has + successfully set the index labels for the given Series object. **We can also assign duplicate or nonunique indexes in Pandas.** From 53696054efbbfa1d329235536fd73b3539c6886a Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Sat, 11 Mar 2023 12:04:08 +0530 Subject: [PATCH 04/26] Update series.py New update. --- pandas/core/series.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 1d4fabde3576b..e980c54c096e0 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5994,6 +5994,7 @@ def mask( index = properties.AxisProperty( axis=0, doc="The index (axis labels) of the Series." """ + A one-dimensional ndarray with hashable type axis labels. Pandas Series.index attribute is used to get or set the index labels @@ -6005,10 +6006,10 @@ def mask( Returns ------- index + index of the series Examples -------- - **Use the Series.index attribute to set the index label for the given Series object.** From aa00a242c6f0c074870426d80e32dacf37c8cf97 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Sun, 19 Mar 2023 00:35:05 +0530 Subject: [PATCH 05/26] Update series.py --- pandas/core/series.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index e980c54c096e0..c47fc7723c32d 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5993,10 +5993,8 @@ def mask( index = properties.AxisProperty( axis=0, doc="The index (axis labels) of the Series." - """ + """A one-dimensional ndarray with hashable type axis labels. - A one-dimensional ndarray with hashable type axis labels. - Pandas Series.index attribute is used to get or set the index labels of the given Series object.The object supports both integer- and label-based indexing and provides a host of methods for From d3692a5c8aeb6c80f86ed2b24b44ea279f950ff9 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Thu, 23 Mar 2023 11:21:35 +0530 Subject: [PATCH 06/26] Update series.py --- pandas/core/series.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index c47fc7723c32d..4013d27aff262 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5993,7 +5993,9 @@ def mask( index = properties.AxisProperty( axis=0, doc="The index (axis labels) of the Series." - """A one-dimensional ndarray with hashable type axis labels. + """ + + A one-dimensional ndarray with hashable type axis labels. Pandas Series.index attribute is used to get or set the index labels of the given Series object.The object supports both From bd823b5e07cb9a578125d56391a5c6f855a2345c Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Mon, 27 Mar 2023 00:51:22 +0530 Subject: [PATCH 07/26] Update series.py --- pandas/core/series.py | 85 +++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 47 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 4013d27aff262..97bf1487f0379 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5992,58 +5992,49 @@ def mask( _info_axis_name: Literal["index"] = "index" index = properties.AxisProperty( - axis=0, doc="The index (axis labels) of the Series." - """ - - A one-dimensional ndarray with hashable type axis labels. - - Pandas Series.index attribute is used to get or set the index labels - of the given Series object.The object supports both - integer- and label-based indexing and provides a host of methods for - performing operations involving the index. - The labels need not be unique but must be of the hashable type. - + axis=0, doc="""The index (axis labels) of the Series. + + Get the index (row labels) of the Series. + Returns ------- - index - index of the series + Index + The index labels of the Series. + + See Also + -------- + Series.reindex: + Conform Series to new index. + Series.set_index: + Set Series as DataFrame index. + Index: + The base pandas index type. + + Notes + ----- + The index of a Series is used to label and identify each element of the + underlying data. The index can be thought of as an immutable ordered set + (technically a multi-set, as it may contain duplicate labels), and is + used to index and align data in pandas. + + For more information on pandas indexing, see the `indexing user guide + `__. Examples -------- - **Use the Series.index attribute to set the index label for - the given Series object.** - - >>> s = pd.Series(['Kolkata', 'Chicago', 'Toronto', 'Lisbon']) - >>> print(s) - 0 Kolkata - 1 Chicago - 2 Toronto - 3 Lisbon - dtype: object - - The ``Series.index`` attribute will now be used to set the index - label for the given object. - - >>> s.index = ['City 1', 'City 2', 'City 3', 'City 4'] - >>> print(s) - City 1 Kolkata - City 2 Chicago - City 3 Toronto - City 4 Lisbon - dtype: object - - As we can see in the output, the ``Series.index`` attribute has - successfully set the index labels for the given Series object. - - **We can also assign duplicate or nonunique indexes in Pandas.** - - >>> s.index = ['City 1', 'City 1', 'City 3', 'City 3'] - >>> print(s) - City 1 Kolkata - City 1 Chicago - City 3 Toronto - City 3 Lisbon - dtype: object + To create a Series with a custom index and view the index labels: + + >>> cities = ['Kolkata', 'Chicago', 'Toronto', 'Lisbon'] + >>> populations = [14.85, 2.71, 2.93, 0.51] + >>> city_series = pd.Series(populations, index=cities) + >>> city_series.index + Index(['Kolkata', 'Chicago', 'Toronto', 'Lisbon'], dtype='object') + + To change the index labels of an existing Series: + + >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] + >>> city_series.index + Index(['KOL', 'CHI', 'TOR', 'LIS'], dtype='object') """ ) From f3c576b49491f6da024eb561146954f97bfd835c Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:53:00 +0530 Subject: [PATCH 08/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 80a2533d8a0f8..f1f1c0ed36c40 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5770,7 +5770,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series (technically a multi-set, as it may contain duplicate labels), and is used to index and align data in pandas. - For more information on pandas indexing, see the `indexing user guide + For more information on pandas indexing, see the `indexing user guide `__. Examples From 17da3700c43702d801fe5404f531bb290d08e5b1 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:53:18 +0530 Subject: [PATCH 09/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index f1f1c0ed36c40..409cb77009967 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5788,7 +5788,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] >>> city_series.index Index(['KOL', 'CHI', 'TOR', 'LIS'], dtype='object') - """ + """, ) # ---------------------------------------------------------------------- From c5c8720dcec70b83fd604c3fb0118c22b3b310fe Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:53:39 +0530 Subject: [PATCH 10/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 409cb77009967..ec28c05fa03b0 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5756,11 +5756,11 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series See Also -------- - Series.reindex: + Series.reindex: Conform Series to new index. - Series.set_index: + Series.set_index: Set Series as DataFrame index. - Index: + Index: The base pandas index type. Notes From 9c311eac7f19faef32a985cc665d80a1e1980995 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:53:57 +0530 Subject: [PATCH 11/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index ec28c05fa03b0..8fcc20e113bce 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5745,7 +5745,9 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series _info_axis_name: Literal["index"] = "index" index = properties.AxisProperty( - axis=0, doc="""The index (axis labels) of the Series. + axis=0, + doc=""" + The index (axis labels) of the Series. Get the index (row labels) of the Series. From 14bb84821aae12a90ef980c20f92ec801df74d7e Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 4 Apr 2023 19:57:47 +0530 Subject: [PATCH 12/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 8fcc20e113bce..6f73b1fb4c901 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,7 +5748,6 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. - Get the index (row labels) of the Series. Returns From ddb0fda094f0ac810dfb08daf94cc9e4b34a00f7 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 4 Apr 2023 19:58:33 +0530 Subject: [PATCH 13/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 6f73b1fb4c901..f393081db96d9 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5745,7 +5745,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series _info_axis_name: Literal["index"] = "index" index = properties.AxisProperty( - axis=0, + axis=0, doc=""" The index (axis labels) of the Series. Get the index (row labels) of the Series. From 4d70353a24efb5a176f40d334c065e82ae8f228f Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 4 Apr 2023 23:41:56 +0530 Subject: [PATCH 14/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index f393081db96d9..b478f6c18db43 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,7 +5748,8 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. - Get the index (row labels) of the Series. + + Get the index (row labels) of the Series. Returns ------- From 156fca442dbe22f64b5d25212f528c9f2e96d4a9 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Thu, 6 Apr 2023 17:07:55 +0530 Subject: [PATCH 15/26] Update series.py --- pandas/core/series.py | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index b478f6c18db43..afd04887e4763 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5751,13 +5751,13 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series Get the index (row labels) of the Series. - Returns - ------- - Index - The index labels of the Series. + Returns + ------- + Index + The index labels of the Series. - See Also - -------- + See Also + -------- Series.reindex: Conform Series to new index. Series.set_index: @@ -5765,32 +5765,32 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series Index: The base pandas index type. - Notes - ----- - The index of a Series is used to label and identify each element of the - underlying data. The index can be thought of as an immutable ordered set - (technically a multi-set, as it may contain duplicate labels), and is - used to index and align data in pandas. + Notes + ----- + The index of a Series is used to label and identify each element of the + underlying data. The index can be thought of as an immutable ordered set + (technically a multi-set, as it may contain duplicate labels), and is + used to index and align data in pandas. - For more information on pandas indexing, see the `indexing user guide - `__. + For more information on pandas indexing, see the `indexing user guide + `__. - Examples - -------- - To create a Series with a custom index and view the index labels: + Examples + -------- + To create a Series with a custom index and view the index labels: - >>> cities = ['Kolkata', 'Chicago', 'Toronto', 'Lisbon'] - >>> populations = [14.85, 2.71, 2.93, 0.51] - >>> city_series = pd.Series(populations, index=cities) - >>> city_series.index - Index(['Kolkata', 'Chicago', 'Toronto', 'Lisbon'], dtype='object') + >>> cities = ['Kolkata', 'Chicago', 'Toronto', 'Lisbon'] + >>> populations = [14.85, 2.71, 2.93, 0.51] + >>> city_series = pd.Series(populations, index=cities) + >>> city_series.index + Index(['Kolkata', 'Chicago', 'Toronto', 'Lisbon'], dtype='object') - To change the index labels of an existing Series: + To change the index labels of an existing Series: - >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] - >>> city_series.index - Index(['KOL', 'CHI', 'TOR', 'LIS'], dtype='object') - """, + >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] + >>> city_series.index + Index(['KOL', 'CHI', 'TOR', 'LIS'], dtype='object') + """, ) # ---------------------------------------------------------------------- From fc3c0ed3449ead2669a4b6ac399c3bf4656c4089 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 7 Apr 2023 00:07:21 +0530 Subject: [PATCH 16/26] Update series.py --- pandas/core/series.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index afd04887e4763..60ec6802d0eca 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,14 +5748,14 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. - - Get the index (row labels) of the Series. + Get the index (row labels) of the Series. + Returns ------- Index The index labels of the Series. - + See Also -------- Series.reindex: @@ -5764,29 +5764,28 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series Set Series as DataFrame index. Index: The base pandas index type. - + Notes ----- The index of a Series is used to label and identify each element of the underlying data. The index can be thought of as an immutable ordered set (technically a multi-set, as it may contain duplicate labels), and is used to index and align data in pandas. - + For more information on pandas indexing, see the `indexing user guide `__. Examples -------- To create a Series with a custom index and view the index labels: - + >>> cities = ['Kolkata', 'Chicago', 'Toronto', 'Lisbon'] >>> populations = [14.85, 2.71, 2.93, 0.51] >>> city_series = pd.Series(populations, index=cities) >>> city_series.index Index(['Kolkata', 'Chicago', 'Toronto', 'Lisbon'], dtype='object') - + To change the index labels of an existing Series: - >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] >>> city_series.index Index(['KOL', 'CHI', 'TOR', 'LIS'], dtype='object') From 680a0a71f970ab4c9cb1a40f78b188548213c339 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:02:38 +0530 Subject: [PATCH 17/26] Update series.py --- pandas/core/series.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 60ec6802d0eca..d37dd276d7d70 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,14 +5748,13 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. - Get the index (row labels) of the Series. - + Returns ------- Index The index labels of the Series. - + See Also -------- Series.reindex: @@ -5764,27 +5763,26 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series Set Series as DataFrame index. Index: The base pandas index type. - + Notes ----- The index of a Series is used to label and identify each element of the underlying data. The index can be thought of as an immutable ordered set (technically a multi-set, as it may contain duplicate labels), and is used to index and align data in pandas. - + For more information on pandas indexing, see the `indexing user guide `__. - Examples -------- To create a Series with a custom index and view the index labels: - + >>> cities = ['Kolkata', 'Chicago', 'Toronto', 'Lisbon'] >>> populations = [14.85, 2.71, 2.93, 0.51] >>> city_series = pd.Series(populations, index=cities) >>> city_series.index Index(['Kolkata', 'Chicago', 'Toronto', 'Lisbon'], dtype='object') - + To change the index labels of an existing Series: >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] >>> city_series.index From a1cf36d8defee507ce96e8e4151966b8bf02e161 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 7 Apr 2023 20:13:54 +0530 Subject: [PATCH 18/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index d37dd276d7d70..81c91dd9c0019 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5783,6 +5783,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series >>> city_series.index Index(['Kolkata', 'Chicago', 'Toronto', 'Lisbon'], dtype='object') + To change the index labels of an existing Series: >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] >>> city_series.index From 62be40a3ec594ffc3ded2c1c8a9496abe5f48775 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 7 Apr 2023 20:16:28 +0530 Subject: [PATCH 19/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 81c91dd9c0019..0a08e7e3ec483 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5757,12 +5757,9 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series See Also -------- - Series.reindex: - Conform Series to new index. - Series.set_index: - Set Series as DataFrame index. - Index: - The base pandas index type. + Series.reindex : Conform Series to new index. + Series.set_index : Set Series as DataFrame index. + Index : The base pandas index type. Notes ----- From 5c5dd5ba95db1e4db29e79c8dae3ea7f3a1c3246 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 7 Apr 2023 20:16:40 +0530 Subject: [PATCH 20/26] Update pandas/core/series.py Co-authored-by: Philip Meier --- pandas/core/series.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 0a08e7e3ec483..8c82b20739df3 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5770,6 +5770,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series For more information on pandas indexing, see the `indexing user guide `__. + Examples -------- To create a Series with a custom index and view the index labels: From 22da74848571b2977bf0da42fa30f277eb06b8e6 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:30:23 +0530 Subject: [PATCH 21/26] Update series.py --- pandas/core/series.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 8c82b20739df3..a9980c050e5fd 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5781,7 +5781,6 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series >>> city_series.index Index(['Kolkata', 'Chicago', 'Toronto', 'Lisbon'], dtype='object') - To change the index labels of an existing Series: >>> city_series.index = ['KOL', 'CHI', 'TOR', 'LIS'] >>> city_series.index From ec0335e52b06db89c8ee8ec5a5bd62e97df0e9da Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:02:54 +0530 Subject: [PATCH 22/26] Update series.py --- pandas/core/series.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index a9980c050e5fd..c9aca622a225a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,6 +5748,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. + Get the index (row labels) of the Series. Returns From 87fccff4d5df4c3f985154ed568f847c7a9cbe94 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Wed, 12 Apr 2023 00:16:31 +0530 Subject: [PATCH 23/26] Update series.py --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index c9aca622a225a..23d12bd147507 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,7 +5748,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. - + Get the index (row labels) of the Series. Returns From c98e6e2459e05b8ae5fd7d75993680392c83756d Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Thu, 13 Apr 2023 11:54:15 +0530 Subject: [PATCH 24/26] Update series.py --- pandas/core/series.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 23d12bd147507..f4a5486dfaa70 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,8 +5748,11 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. - - Get the index (row labels) of the Series. + + The index of a Series is used to label and identify each element of the + underlying data. The index can be thought of as an immutable ordered set + (technically a multi-set, as it may contain duplicate labels), and is + used to index and align data in pandas. Returns ------- @@ -5764,11 +5767,6 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series Notes ----- - The index of a Series is used to label and identify each element of the - underlying data. The index can be thought of as an immutable ordered set - (technically a multi-set, as it may contain duplicate labels), and is - used to index and align data in pandas. - For more information on pandas indexing, see the `indexing user guide `__. From cb41a90a7351eb7a1ab9e6a344325d5e455b33de Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Thu, 13 Apr 2023 18:56:52 +0530 Subject: [PATCH 25/26] Update series.py --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index f4a5486dfaa70..6551ba5b6761d 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5748,7 +5748,7 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series axis=0, doc=""" The index (axis labels) of the Series. - + The index of a Series is used to label and identify each element of the underlying data. The index can be thought of as an immutable ordered set (technically a multi-set, as it may contain duplicate labels), and is From 72c6ad281460b553ddf2494d2302a64e2c90d278 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Thu, 13 Apr 2023 19:02:12 +0530 Subject: [PATCH 26/26] Update code_checks.sh DOC add example of Series.index #51842 --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 45df480779ee7..c046d55d80b49 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -85,7 +85,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (EX01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \ - pandas.Series.index \ pandas.Series.__iter__ \ pandas.Series.keys \ pandas.Series.item \