-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
DOC add example of DataFrame.index #52835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
>>> 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
""" | ||
) | ||
columns = properties.AxisProperty(axis=0, doc="The column labels of the DataFrame.") | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't add this, we generally recommend to_numpy instead of values