Skip to content

Series .equals does not ignore NaNs #8797

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
rockg opened this issue Nov 12, 2014 · 3 comments
Closed

Series .equals does not ignore NaNs #8797

rockg opened this issue Nov 12, 2014 · 3 comments

Comments

@rockg
Copy link
Contributor

rockg commented Nov 12, 2014

This is a datatype thing I believe. When I construct a DataFrame and then compare rows of that, NaNs are not ignored contrary to the documentation.

import pandas as pd
import numpy as np
a = pd.DataFrame([{'A': 1, 'B': 'b', 'C': np.NAN}, {'A': 1, 'B': 'b', 'C': 1}])
b = pd.DataFrame([{'A': 1, 'B': 'b', 'C': np.NAN}, {'A': 1, 'B': 'b', 'C': 1}])

a.loc[0]
A      1
B      b
C    NaN
Name: 0, dtype: object
aa = a.loc[0]
bb = b.loc[0]
aa.equals(bb)
False

# which essentially does this in Block
aa.values == bb.values
Out[35]: array([ True,  True, False], dtype=bool)

Constructing the series outright works as advertised.

a = pd.Series({'A': 1, 'B': 'b', 'C': np.NAN})
b = pd.Series({'A': 1, 'B': 'b', 'C': np.NAN})
a.equals(b)
True
a.values == b.values
Out[30]: array([ True,  True,  True], dtype=bool)
@jorisvandenbossche
Copy link
Member

What version of pandas? Works for me in 0.15.1

@rockg
Copy link
Contributor Author

rockg commented Nov 12, 2014

0.14.0. Glad to hear it's fixed. I'll close.

@rockg rockg closed this as completed Nov 12, 2014
@jorisvandenbossche
Copy link
Member

Possibly fixed by #8443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants