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

NaN in columns produces TypeError #5016

Closed
alefnula opened this issue Sep 28, 2013 · 4 comments · Fixed by #5018

Comments

@alefnula
Copy link
Contributor

commented Sep 28, 2013

>>> 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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Sep 28, 2013

@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

This comment has been minimized.

Copy link
Contributor

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
Projects
None yet
2 participants
You can’t perform that action at this time.