Skip to content

DOC: Updates Index.reindex docstrings (#40328) #40879

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

Closed
wants to merge 10 commits into from

Conversation

lnros
Copy link

@lnros lnros commented Apr 11, 2021

  • closes DOC: pandas Index.reindex #40328: explains function parameters and gives basic example
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

@pep8speaks
Copy link

pep8speaks commented Apr 11, 2021

Hello @lnros! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 291:13: E126 continuation line over-indented for hanging indent
Line 375:89: E501 line too long (91 > 88 characters)
Line 3427:89: E501 line too long (94 > 88 characters)
Line 3664:17: E126 continuation line over-indented for hanging indent
Line 3819:47: W291 trailing whitespace
Line 3820:46: W291 trailing whitespace
Line 3821:50: W291 trailing whitespace
Line 4038:25: E126 continuation line over-indented for hanging indent
Line 4856:17: E126 continuation line over-indented for hanging indent
Line 4858:13: E122 continuation line missing indentation or outdented
Line 4859:13: E122 continuation line missing indentation or outdented
Line 4860:9: E122 continuation line missing indentation or outdented

Comment last updated at 2021-05-25 11:23:31 UTC


Parameters
----------
target : an iterable
method : {None, ‘backfill’/’bfill’, ‘pad’/’ffill’, ‘nearest’}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to share parts with NDFrame.reindex?

Copy link
Author

Choose a reason for hiding this comment

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

Maybe share parts with other functions in this same file, such as get_indexer? @phofl

Copy link
Member

Choose a reason for hiding this comment

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

I think in this case you can better use , optional at the end, instead of having None in the list.

I don't think we ever use these forward ticks, can you check other docstrings to see if we use quotes at all or what.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @lnros, and sorry for the delay in reviewing. Great contribution, added some small comments about the standards we use, but looks great. Ping me when you address the comments, and the CI is green, and I'll have another look.


Parameters
----------
target : an iterable
method : {None, ‘backfill’/’bfill’, ‘pad’/’ffill’, ‘nearest’}
Copy link
Member

Choose a reason for hiding this comment

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

I think in this case you can better use , optional at the end, instead of having None in the list.

I don't think we ever use these forward ticks, can you check other docstrings to see if we use quotes at all or what.

- pad / ffill: Propagate last valid observation forward to next valid.
- backfill / bfill: Use next valid observation to fill gap.
- nearest: Use nearest valid observations to fill gap.
level : int or name
Copy link
Member

Choose a reason for hiding this comment

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

These are types, I guess it should be int or str?

level : int or name
Broadcast across a level, matching Index values on
the passed MultiIndex level.
limit : int, default None
Copy link
Member

Choose a reason for hiding this comment

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

int, optional

the passed MultiIndex level.
limit : int, default None
Maximum number of consecutive elements to forward or backward fill.
tolerance : optional
Copy link
Member

Choose a reason for hiding this comment

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

Type should be something like int or list-like of int, optional I think.

>>> index = ['a', 'b', 'c', 'd']
>>> df = pd.DataFrame({"A": [1,2,3,4],
... "B": [5,6,7,8],
... "C": [9,10,11,12]},
Copy link
Member

Choose a reason for hiding this comment

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

PEP-8 requires spaces ater commas, can you add them please, and make sure this is PEP-8 compliant.

>>> target, indexer = df.index.reindex(target=['I', 'II', 'III', 'IV'])
>>> target, indexer
(Index(['I', 'II', 'III', 'IV'], dtype='object'), array([-1, -1, -1, -1]))
>>> target, indexer = df.index.reindex(target=['I', 'd', 'a', 'IV'])
Copy link
Member

Choose a reason for hiding this comment

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

Can you check the failure on the CI? These tests are failing, something is not right. You can test the code locally using the master version of pandas.

After you fix these things, can you check that the CI is green, so we can merge.

@datapythonista datapythonista added Docs Index Related to the Index class or subclasses labels May 7, 2021
@simonjayhawkins
Copy link
Member

@lnros can you merge master to resolve conflicts

@lnros
Copy link
Author

lnros commented May 25, 2021

@simonjayhawkins Done

@datapythonista
Copy link
Member

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@jreback
Copy link
Contributor

jreback commented Sep 1, 2021

closing as stale

@jreback jreback closed this Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: pandas Index.reindex
6 participants