Skip to content
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

DOC add example of DataFrame.index #52835

Merged
merged 5 commits into from Apr 23, 2023
Merged

DOC add example of DataFrame.index #52835

merged 5 commits into from Apr 23, 2023

Conversation

ggold7046
Copy link
Contributor

DOC add example of DataFrame.index

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

DOC add example of DataFrame.index
@ggold7046
Copy link
Contributor Author

Here is the screenshots.

DataFrame
DataFrame2

@ggold7046 ggold7046 changed the title Update frame.py DOC add example of DataFrame.index Apr 21, 2023
See Also
--------
DataFrame.columns : The column labels of the DataFrame.
DataFrame.values : Return a Numpy representation of the DataFrame.
Copy link
Member

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

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Int64Index was removed in 2.0, this is a regular Index now


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reindexed is confusing, rather use update

Updated as per suggestions.
@ggold7046 ggold7046 requested a review from phofl April 22, 2023 13:57
@ggold7046
Copy link
Contributor Author

ggold7046 commented Apr 22, 2023

Hi @phofl , thanks for your suggestions. I have updated the doc. The Code Checks/Pre-commit is failing. I think there is some trailing white-space which I missed.

Is there any documentation organisation or information architecture related issue there in pandas that I can do ?

@phofl
Copy link
Member

phofl commented Apr 22, 2023

You can run pre-commit locally to fix the problems

@ggold7046
Copy link
Contributor Author

I checked with python scripts/validate_docstrings.py pandas.DataFrame.index and it returned Docstring for "pandas.DataFrame.index" correct. :) .

@phofl
Copy link
Member

phofl commented Apr 22, 2023

Please check https://pandas.pydata.org/docs/development/contributing_codebase.html#contributing-pre-commit

The section explains how to run pre-commit hooks

@ggold7046
Copy link
Contributor Author

ggold7046 commented Apr 22, 2023

I ran pre-commit and I got this result.

Pre-commit

(pandas-dev) gitpod > /workspace/pandas $ pre-commit run --files frame.py

[INFO] Initializing environment for local:black==23.1.0.
[INFO] Initializing environment for https://github.com/charliermarsh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/jendrikseipp/vulture.
[INFO] Initializing environment for https://github.com/codespell-project/codespell.
[INFO] Initializing environment for https://github.com/codespell-project/codespell:tomli.
[INFO] Initializing environment for https://github.com/MarcoGorelli/cython-lint.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/cpplint/cpplint.
[INFO] Initializing environment for https://github.com/pycqa/pylint.
[INFO] Initializing environment for https://github.com/PyCQA/isort.
[INFO] Initializing environment for https://github.com/asottile/pyupgrade.
[INFO] Initializing environment for https://github.com/pre-commit/pygrep-hooks.
[INFO] Initializing environment for https://github.com/sphinx-contrib/sphinx-lint.
[INFO] Initializing environment for local:pyright@1.1.292.
[INFO] Initializing environment for local.
[INFO] Initializing environment for local:tomli,pyyaml.
[INFO] Initializing environment for local:autotyping==23.3.0,libcst==0.4.9.
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/charliermarsh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/jendrikseipp/vulture.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/codespell-project/codespell.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/MarcoGorelli/cython-lint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/cpplint/cpplint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/asottile/pyupgrade.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/sphinx-contrib/sphinx-lint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
black...............................................................................(no files to check)Skipped
ruff................................................................................(no files to check)Skipped
vulture.............................................................................(no files to check)Skipped
codespell...........................................................................(no files to check)Skipped
cython-lint.........................................................................(no files to check)Skipped
double-quote Cython strings.........................................................(no files to check)Skipped
debug statements (python)...........................................................(no files to check)Skipped
fix end of files....................................................................(no files to check)Skipped
trim trailing whitespace............................................................(no files to check)Skipped
cpplint.............................................................................(no files to check)Skipped
isort...............................................................................(no files to check)Skipped
pyupgrade...........................................................................(no files to check)Skipped
rst code is two backticks.......................................................(no files to check)Skipped
rst directives end with two colons..................................................(no files to check)Skipped
rst inline code next to normal text.............................................(no files to check)Skipped
Sphinx lint.........................................................................(no files to check)Skipped
Check for inconsistent use of pandas namespace......................................(no files to check)Skipped
Check code for instances of os.remove...............................................(no files to check)Skipped
Unwanted patterns...................................................................(no files to check)Skipped
Check Cython casting is <type>obj, not <type> obj...............................(no files to check)Skipped
Check for backticks incorrectly rendering because of missing spaces.................(no files to check)Skipped
Check for unnecessary random seeds in asv benchmarks................................(no files to check)Skipped
Check for usage of numpy testing or array_equal.....................................(no files to check)Skipped
Check for invalid EA testing........................................................(no files to check)Skipped
Unwanted patterns in tests..........................................................(no files to check)Skipped
Unwanted patterns in EA tests.......................................................(no files to check)Skipped
Unwanted patterns in Cython code....................................................(no files to check)Skipped
Generate pip dependency from conda..................................................(no files to check)Skipped
Validate correct capitalization among titles in documentation.......................(no files to check)Skipped
Check for use of bare pytest raises.................................................(no files to check)Skipped
Check for use of private functions across modules...................................(no files to check)Skipped
Check for import of private attributes across modules...............................(no files to check)Skipped
Check for strings with misplaced spaces.............................................(no files to check)Skipped
Import pandas.array as pd_array in core.............................................(no files to check)Skipped
Use pandas.io.common.urlopen instead of urllib.request.urlopen......................(no files to check)Skipped
Use bool_t instead of bool in pandas/core/generic.py................................(no files to check)Skipped
Use raise instead of return for exceptions..........................................(no files to check)Skipped
Ensure pandas errors are documented in doc/source/reference/testing.rst.............(no files to check)Skipped
Check for pg8000 not installed on CI for test_pg8000_sqlalchemy_passthrough_error...(no files to check)Skipped
Check minimum version of dependencies are aligned...................................(no files to check)Skipped
Validate errors locations...........................................................(no files to check)Skipped
import annotations from future..................................................(no files to check)Skipped
check that test names start with 'test'.............................................(no files to check)Skipped
sort whatsnew entries alphabetically................................................(no files to check)Skipped

@phofl
Copy link
Member

phofl commented Apr 22, 2023

you have to run pre-commit run --all-files if its not active while committing

@ggold7046
Copy link
Contributor Author

Thanks @phofl, I think this time it will pass the test.

I wanted to know if there is any documentation organisation or information architecture type of issue is there in pandas ? I want to work on this type of issues too.

@phofl
Copy link
Member

phofl commented Apr 22, 2023

You'll have to search the issue tracker

@ggold7046
Copy link
Contributor Author

ggold7046 commented Apr 23, 2023

Some ci checks has failed. Could you suggest how to rectify it ?

DOC add example of DataFrame.index #52835
@phofl
Copy link
Member

phofl commented Apr 23, 2023

This is related to changes in NumPy, not your PR. so you don't have to worry about it

@ggold7046
Copy link
Contributor Author

Thanks @phofl

pandas/core/frame.py Outdated Show resolved Hide resolved
Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
@phofl phofl added the Docs label Apr 23, 2023
@phofl phofl added this to the 2.1 milestone Apr 23, 2023
@phofl phofl merged commit 7b710c7 into pandas-dev:main Apr 23, 2023
40 of 41 checks passed
@phofl
Copy link
Member

phofl commented Apr 23, 2023

thx @ggold7046

@ggold7046 ggold7046 deleted the patch-1 branch April 24, 2023 07:18
@ggold7046
Copy link
Contributor Author

documentation organisation or information architecture type of issue is there in pandas ?

Hi @phofl , could you please tell me how do I search documentation organisation or information architecture type of issue in pandas issue tracker?

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants