-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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: update the Index.isin docstring #20249
DOC: update the Index.isin docstring #20249
Conversation
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.
Thanks! A few comments.
pandas/core/indexes/base.py
Outdated
@@ -3112,8 +3112,11 @@ def map(self, mapper, na_action=None): | |||
|
|||
def isin(self, values, level=None): | |||
""" | |||
Boolean array on existence of index values in `values`. |
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.
Does
Return a boolean array where the index values are in `values`.
fit on a line?
pandas/core/indexes/base.py
Outdated
Compute boolean array of whether each index value is found in the | ||
passed set of values. | ||
passed set of values. Length of the returned boolean array matches |
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.
"Length" -> "The length"
pandas/core/indexes/base.py
Outdated
|
||
level : str or int, optional | ||
level : str or int, optional in the case of Index, compulsory on |
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.
Not quite, it's always optional but we don't handle it properly see #20252
pandas/core/indexes/base.py
Outdated
array([ True, False, False]) | ||
|
||
>>> midx = pd.MultiIndex.from_arrays([[1,2,3], | ||
... ['red','blue','green']], |
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.
PEP8: align these.
pandas/core/indexes/base.py
Outdated
... ['red','blue','green']], | ||
... names=('number', 'color')) | ||
>>> midx | ||
MultiIndex(levels=[[1, 2, 3], ['blue', 'green', 'red']],\ |
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.
Don't worry about the trailing backslashes here. Just line things up.
pandas/core/indexes/base.py
Outdated
Check whether a string index value is in the 'color' level of the | ||
MultiIndex: | ||
|
||
>>> midx.isin(['red'],'color') |
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.
PEP8: space after comma
Explicit keyword argument, so level='color'
.
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.
Could you add an example with no level, midx.isin([(1, 'red'), (3, 'red')])
pandas/core/indexes/base.py
Outdated
>>> dti = pd.to_datetime(dates) | ||
>>> dti | ||
DatetimeIndex(['2000-03-11', '2000-03-12', '2000-03-13'],\ | ||
dtype='datetime64[ns]', freq=None) |
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.
formatting
pandas/core/indexes/base.py
Outdated
See also | ||
-------- | ||
DatetimeIndex.isin : an Index of :class:`Datetime` s | ||
TimedeltaIndex : an Index of :class:`Timedelta` s |
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.
you don't need any of these. however pls add Series.isin
@noemielteto Do you have time to update the PR based on the feedback? |
@jorisvandenbossche Yes, I am going to update it today. |
bf6307b
to
b18d848
Compare
Codecov Report
@@ Coverage Diff @@
## master #20249 +/- ##
==========================================
- Coverage 91.79% 91.77% -0.03%
==========================================
Files 152 152
Lines 49205 49205
==========================================
- Hits 45169 45159 -10
- Misses 4036 4046 +10
Continue to review full report at Codecov.
|
[ci skip]
Rephrased the examples slightly. Instead of saying "check whether a string is in the index", we say "check whether each value in the index is in a list of strings." Subtle difference, but "string in index" is more like Thanks @noemielteto! |
@TomAugspurger Totally agree, thanks! |
@TomAugspurger Just wondering - what is this 15mb file that got merged in with the pull request? |
Remnant of pandas-devgh-20249.
@emesterhazy : That's a file that no longer exists 😄 (it should never have been there, not sure why it wasn't caught before merging). |
I believe it's still present. cc @jreback @jorisvandenbossche. We have
Merge end (newest on top) The size of a fresh clone: $ git count-objects -vH
count: 0
size: 0 bytes
in-pack: 145618
packs: 1
size-pack: 120.35 MiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes Cleanup with bfg
|
Here's the log after
Do we want to force push that to master? That'll cause some short term pain probably, but I think it's for the best. I'll wait for a +1, and I suspect @jreback will have to temporarily disable branch protection on master. |
@TomAugspurger do you want to do a force push to master? |
I'm trying to read a bit more about how that messes up downstream. It seems to be a pretty bad idea. |
FYI, those outputs I posted are out of date due to #20402 being merged. I re-ran bfg with latest master including that change.
And here's the new log
I haven't force pushed yet. |
@TomAugspurger ok to force push. I did this once before a long time ago. just be careful! |
you may have to set the no-force push flag (in settings), then do it, then revert the flag |
Done. Re-enabled branch protection on master. Could someone check the settings? I think that's how they were before. |
Everything looks ok |
@TomAugspurger : Yes, I did remove that file in that commit. |
Remnant of pandas-devgh-20249.
Yeah, it was still around in the git history though. So I used bfg to purge it from the history (rewriting master) and force pushed. We should probably have some kind of policy around that. OK to do if you notice it right away and master hasn't changed? Wait for a +1 otherwise? |
That makes sense. |
Revert "DOC: update the Index.isin docstring (pandas-dev#20249)" This reverts commit 4a43815.
Revert "DOC: update the Index.isin docstring (pandas-dev#20249)" This reverts commit 4a43815.
…ame_describe * upstream/master: (158 commits) Add link to "Craft Minimal Bug Report" blogpost (pandas-dev#20431) BUG: fixed json_normalize for subrecords with NoneTypes (pandas-dev#20030) (pandas-dev#20399) BUG: ExtensionArray.fillna for scalar values (pandas-dev#20412) DOC" update the Pandas core window rolling count docstring" (pandas-dev#20264) DOC: update the pandas.DataFrame.plot.hist docstring (pandas-dev#20155) DOC: Only use ~ in class links to hide prefixes. (pandas-dev#20402) Bug: Allow np.timedelta64 objects to index TimedeltaIndex (pandas-dev#20408) DOC: add disallowing of Series construction of len-1 list with index to whatsnew (pandas-dev#20392) MAINT: Remove weird pd file DOC: update the Index.isin docstring (pandas-dev#20249) BUG: Handle all-NA blocks in concat (pandas-dev#20382) DOC: update the pandas.core.resample.Resampler.fillna docstring (pandas-dev#20379) BUG: Don't raise exceptions splitting a blank string (pandas-dev#20067) DOC: update the pandas.DataFrame.cummax docstring (pandas-dev#20336) DOC: update the pandas.core.window.x.mean docstring (pandas-dev#20265) DOC: update the api.types.is_number docstring (pandas-dev#20196) Fix linter (pandas-dev#20389) DOC: Improved the docstring of pandas.Series.dt.to_pytimedelta (pandas-dev#20142) DOC: update the pandas.Series.dt.is_month_end docstring (pandas-dev#20181) DOC: update the window.Rolling.min docstring (pandas-dev#20263) ...
Remnant of pandas-devgh-20249.
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.