Skip to content

NaN in columns produces TypeError #5016

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
alefnula opened this issue Sep 28, 2013 · 4 comments · Fixed by #5018
Closed

NaN in columns produces TypeError #5016

alefnula opened this issue Sep 28, 2013 · 4 comments · Fixed by #5018
Labels
Enhancement Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@alefnula
Copy link
Contributor

>>> pd.DataFrame([[1,2,3]], columns=[1.1,2.2,np.nan])
Traceback (most recent call last):
...
TypeError: ("'NoneType' object is not iterable", u'occurred at index 2.2')

Is this a bug or a feature? I don't see anything about that in the v0.13.0.txt, and it worked in 0.12:

>>> pd.DataFrame([[1,2,3]], columns=[1.1,2.2,np.nan])
    1.1   2.2  NaN
0     1     2     3
@jreback
Copy link
Contributor

jreback commented Sep 28, 2013

This is a quite tricky and non-trivial bug. It didn't work before, just didn't error. Not really sure it should even be allowed. (but is supported in some places).

@jreback
Copy link
Contributor

jreback commented Sep 28, 2013

Its not very useful; you end up defeating name based indexing, eg. df[np.nan] doesn't even make sense

@alefnula
Copy link
Contributor Author

@jreback I found this when I tried to reproduce the issue #4987 in 0.13.

>>> df = pd.read_html(
             'http://en.wikipedia.org/wiki/Vancouver',
             match='Municipality', header=0
         )[0]
>>> df
0         Country         Municipality   NaN
1         Ukraine               Odessa  1944
2           Japan             Yokohama  1965
3  United Kingdom  Edinburgh[198][199]  1978
4           China       Guangzhou[200]  1985
5   United States          Los Angeles  1986
6     South Korea                Seoul  2007

This is the result in 0.12, in 0.13 it just brakes... Maybe this should be a bug on the read_html function then?

@jreback
Copy link
Contributor

jreback commented Sep 28, 2013

@alefnula thanks for pointing this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants