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

get_dummies with NaN #4446

Closed
hayd opened this issue Aug 2, 2013 · 1 comment · Fixed by #4458
Closed

get_dummies with NaN #4446

hayd opened this issue Aug 2, 2013 · 1 comment · Fixed by #4458
Labels
Milestone

Comments

@hayd
Copy link
Contributor

hayd commented Aug 2, 2013

get_dummies seems to get caught out by NaNs

In [11]: s1 = pd.Series(['a', 'a', np.nan, 'c', 'c', 'c'])

In [12]: s1
Out[12]: 
0      a
1      a
2    NaN
3      c
4      c
5      c
dtype: object

In [13]: pd.get_dummies(s1)
Out[13]: 
   a  c
0  1  0
1  1  0
2  0  1
3  0  1
4  0  1
5  0  1

A rogue c has been used as the NaN value, I think expected is:

In [14]: pd.get_dummies(s1[s1.notnull()])
Out[14]: 
   a  c
0  1  0
1  1  0
3  0  1
4  0  1
5  0  1
@hayd
Copy link
Contributor Author

hayd commented Aug 3, 2013

fix for this on the way (cat.labels == -1 for NaN was the issue).

This was referenced Aug 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant