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

Misbehaved reindexing with NaN labels #522

Closed
wesm opened this issue Dec 21, 2011 · 1 comment

Comments

@wesm
Copy link
Member

commented Dec 21, 2011

from user report

In [116]: df = pandas.DataFrame([[1,2], [3,4], [numpy.nan,numpy.nan], [7,8], [9,10]], columns=['a', 'b'], index=[100.0, 101.0, numpy.nan, 102.0, 103.0])                 

In [117]: print df

--------> print(df)

       a    b

100.0  1    2

101.0  3    4

nan    NaN  NaN

102.0  7    8

103.0  9    10



#referencing anything after the nan in the index results in getting nans!

In [118]: df.reindex(index=[101.0, 102.0, 103.0])

Out[118]:

       a    b

101.0  3    4

102.0  NaN  NaN

103.0  NaN  NaN



#after nan = NaN again!

In [119]: df.reindex(index=[103.0])

Out[119]:

       a    b

103.0  NaN  NaN



#before nan looks good though

In [120]: df.reindex(index=[101.0])

Out[119]:

       a    b

101.0  3    4
@changhiskhan

This comment has been minimized.

Copy link
Contributor

commented May 7, 2012

Looks like this has been fixed on master already.

In [8]: df = pandas.DataFrame([[1,2], [3,4], [numpy.nan,numpy.nan], [7,8], [9,10]], columns=['a', 'b'], index=[100.0, 101.0, numpy.nan, 102.0, 103.0])

In [9]: df
Out[9]:
a b
100 1 2
101 3 4
NaN NaN NaN
102 7 8
103 9 10

In [10]:

In [10]: df.reindex(index=[101.0, 102.0, 103.0])
Out[10]:
a b
101 3 4
102 7 8
103 9 10

In [11]: df.reindex(index=[103.0])
Out[11]:
a b
103 9 10

In [12]: df.reindex(index=[101.0])
Out[12]:
a b
101 3 4

@wesm wesm closed this in 20f69e7 May 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.