Skip to content

BUG: creating dataframe from empty series raises exception #5756

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
immerrr opened this issue Dec 20, 2013 · 0 comments · Fixed by #5757
Closed

BUG: creating dataframe from empty series raises exception #5756

immerrr opened this issue Dec 20, 2013 · 0 comments · Fixed by #5757
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Milestone

Comments

@immerrr
Copy link
Contributor

immerrr commented Dec 20, 2013

Here's a snippet to show what I'm talking about:

In [1]: pd.__version__
Out[1]: '0.13.0rc1-95-gfec2ff6'

In [2]: pd.DataFrame(pd.Series())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-31c6b8fd30b1> in <module>()
----> 1 pd.DataFrame(pd.Series())

/home/immerrr/sources/pandas/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    230             else:
    231                 mgr = self._init_ndarray(data, index, columns, dtype=dtype,
--> 232                                          copy=copy)
    233         elif isinstance(data, (list, types.GeneratorType)):
    234             if isinstance(data, types.GeneratorType):

/home/immerrr/sources/pandas/pandas/core/frame.py in _init_ndarray(self, values, index, columns, dtype, copy)
    334 
    335             # zero len case (GH #2234)
--> 336             if not len(values) and len(columns):
    337                 values = np.empty((0, 1), dtype=object)
    338 

TypeError: object of type 'NoneType' has no len()

Apparently, it's a regression from 0.12.0, because

In [1]: pd.__version__
Out[1]: '0.12.0'

In [2]: pd.DataFrame(pd.Series())
Out[2]: 
Empty DataFrame
Columns: [0]
Index: []

I'd guess that one of failing checks previously read if smth ..., but since implicit conversion to boolean for ndarrays are now forbidden, the check was replaced by len(smth), but I didn't dig into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant