question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: Typo(s?) in pandas.DataFrame.isin

See original GitHub issue

  • I have checked that the issue still exists on the latest versions of the docs on master here

Location of the documentation

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.isin.html

Documentation problem

In the last example, the text introducing the code snippet reads:

When values is a Series or DataFrame the index and column must match. Note that ‘falcon’ does not match based on the number of legs in df2.

However, “df2” does not exist in the included code snippet (it is instead called “other”).

Additionally, I am not comfortable enough with pandas to assert this, but it seems like the text should incorrectly states that “falcon” does not match, since “falcon” indeed does match for both columns, see the relevant portion of the code snippet:

>>> df.isin(other)
        num_legs  num_wings
falcon      True       True
dog        False      False

Suggested fix for documentation

Text should at least read:

When values is a Series or DataFrame the index and column must match. Note that ‘falcon’ does not match based on the number of legs in other.

or the variable in the code snippet should be renamed to “df2”.

Additionally, something may need to be done to address the potential discrepancy in saying that “falcon” does not match.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
johnzangwillcommented, Sep 29, 2021

@Varun270 Just follow the “contributing” instructions to the letter. Yes, there is a bit of a learning curve…

I suggest that you change your change slightly. You say “Note that ‘falcon’ does not match based on the number of legs in other.” But in fact it does match.

I would change to:

other = pd.DataFrame({'num_legs': [8, 3], 'num_wings': [0, 2]},index=['spider', 'falcon'])

Then you will indeed get the falcon not matching:

 >>> df.isin(other)
                num_legs  num_wings
        falcon     False       True
        dog        False      False
2reactions
MarcoGorellicommented, Sep 29, 2021

you can make a new branch - I recommend the first 3 chapters of this book for getting familiar with the git workflow

Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas.Series.isin — pandas 1.5.2 documentation
Return a boolean Series showing whether each element in the Series matches an element in the passed sequence of values exactly. Parameters. valuesset...
Read more >
pandas.DataFrame.isin — pandas 1.5.2 documentation
DataFrame of booleans showing whether each element in the DataFrame is contained in values. See also. DataFrame.eq. Equality test for DataFrame. Series.isin.
Read more >
pandas.Series.isin — pandas 0.20.1 documentation
Return a boolean Series showing whether each element in the Series is exactly contained in the passed sequence of values .
Read more >
Indexing and selecting data — pandas 1.5.2 documentation
A callable function with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above). See...
Read more >
pandas.DataFrame — pandas 1.5.2 documentation
Access a group of rows and columns by label(s) or a boolean array. ndim. Return an int representing the number of axes /...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found