From c8ae0ab549b079d4a397f4099dfa915365590f58 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Sat, 22 Apr 2023 00:10:59 +0530 Subject: [PATCH 1/5] Update frame.py DOC add example of DataFrame.index --- pandas/core/frame.py | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index bd298b8d723b8..d1c7a009e1d40 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11768,7 +11768,50 @@ def isin(self, values: Series | DataFrame | Sequence | Mapping) -> DataFrame: _info_axis_name: Literal["columns"] = "columns" index = properties.AxisProperty( - axis=1, doc="The index (row labels) of the DataFrame." + axis=1, + doc=""" + The index (row labels) of the DataFrame. + + The index of a DataFrame is a series of labels that identify each row. + The labels can be integers, strings, or any other hashable type. The index + is used for label-based access and alignment, and can be accessed or + modified using this attribute. + + Returns + ------- + pandas.Index + The index labels of the DataFrame. + + See Also + -------- + DataFrame.columns : The column labels of the DataFrame. + DataFrame.values : Return a Numpy representation of the DataFrame. + + Examples + -------- + >>> df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Aritra'], + ... 'Age': [25, 30, 35], + ... 'Location': ['Seattle', 'New York', 'Kona']}, + ... index=([10, 20, 30])) + >>> df.index + Index([10, 20, 30], dtype='int64') + + In this example, we create a DataFrame with 3 rows and 3 columns, + including Name, Age, and Location information. We set the index labels to + be the integers 10, 20, and 30. We then access the `index` attribute of the + DataFrame, which returns an `Int64Index` object containing the index labels. + + >>> df.index = [100, 200, 300] + >>> df + Name Age Location + 100 Alice 25 Seattle + 200 Bob 30 New York + 300 Aritra 35 Kona + + In this example, we modify the index labels of the DataFrame by assigning + a new list of labels to the `index` attribute. The DataFrame is then + reindexed with the new labels, and the output shows the modified DataFrame. + """ ) columns = properties.AxisProperty(axis=0, doc="The column labels of the DataFrame.") From c322dcfa0b086553a370ca5de740b5297b9c46cf Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Sat, 22 Apr 2023 19:26:35 +0530 Subject: [PATCH 2/5] Update frame.py Updated as per suggestions. --- pandas/core/frame.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d1c7a009e1d40..b7c22409249b5 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11785,7 +11785,7 @@ def isin(self, values: Series | DataFrame | Sequence | Mapping) -> DataFrame: See Also -------- DataFrame.columns : The column labels of the DataFrame. - DataFrame.values : Return a Numpy representation of the DataFrame. + DataFrame.to_numpy : Convert the DataFrame to a NumPy array. Examples -------- @@ -11799,7 +11799,7 @@ def isin(self, values: Series | DataFrame | Sequence | Mapping) -> DataFrame: In this example, we create a DataFrame with 3 rows and 3 columns, including Name, Age, and Location information. We set the index labels to be the integers 10, 20, and 30. We then access the `index` attribute of the - DataFrame, which returns an `Int64Index` object containing the index labels. + DataFrame, which returns an `Index` object containing the index labels. >>> df.index = [100, 200, 300] >>> df @@ -11810,7 +11810,7 @@ def isin(self, values: Series | DataFrame | Sequence | Mapping) -> DataFrame: In this example, we modify the index labels of the DataFrame by assigning a new list of labels to the `index` attribute. The DataFrame is then - reindexed with the new labels, and the output shows the modified DataFrame. + update with the new labels, and the output shows the modified DataFrame. """ ) columns = properties.AxisProperty(axis=0, doc="The column labels of the DataFrame.") From 72634ef3c66566a70ab4c4e6df7e581382d21d8b Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Sun, 23 Apr 2023 02:04:44 +0530 Subject: [PATCH 3/5] Update frame.py --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index b7c22409249b5..27715faff5c11 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11811,7 +11811,7 @@ def isin(self, values: Series | DataFrame | Sequence | Mapping) -> DataFrame: In this example, we modify the index labels of the DataFrame by assigning a new list of labels to the `index` attribute. The DataFrame is then update with the new labels, and the output shows the modified DataFrame. - """ + """, ) columns = properties.AxisProperty(axis=0, doc="The column labels of the DataFrame.") From 8c6c0e4587d914f3a554409762a5b68886e7c089 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Sun, 23 Apr 2023 13:40:45 +0530 Subject: [PATCH 4/5] Update code_checks.sh DOC add example of DataFrame.index #52835 --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index c046d55d80b49..55618590071b5 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -532,7 +532,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.api.extensions.ExtensionArray.ndim \ pandas.api.extensions.ExtensionArray.shape \ pandas.api.extensions.ExtensionArray.tolist \ - pandas.DataFrame.index \ pandas.DataFrame.columns \ pandas.DataFrame.__iter__ \ pandas.DataFrame.keys \ From baa5332caf208b85a3c38472987e40718cd6cdf8 Mon Sep 17 00:00:00 2001 From: AG <98327736+ggold7046@users.noreply.github.com> Date: Sun, 23 Apr 2023 19:32:21 +0530 Subject: [PATCH 5/5] Update pandas/core/frame.py Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com> --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 27715faff5c11..abe62b475a759 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11810,7 +11810,7 @@ def isin(self, values: Series | DataFrame | Sequence | Mapping) -> DataFrame: In this example, we modify the index labels of the DataFrame by assigning a new list of labels to the `index` attribute. The DataFrame is then - update with the new labels, and the output shows the modified DataFrame. + updated with the new labels, and the output shows the modified DataFrame. """, ) columns = properties.AxisProperty(axis=0, doc="The column labels of the DataFrame.")