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
BUG: to_records() fails for empty MultiIndex #21064
Labels
Comments
In particular the issue seems to be an empty In [35]: df = pd.DataFrame(columns=['A'], index=pd.MultiIndex([['a'], ['b']], labels=[[], []]))
In [36]: df.to_records()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last) You can workaround this with In [39]: df.to_records(index=False)
Out[39]:
rec.array([],
dtype=[('A', 'O')]) |
chris-b1
changed the title
to_records() fails for empty dataframes after groupby
BUG: to_records() fails for empty MultiIndex
May 15, 2018
fersarr
pushed a commit
to fersarr/pandas
that referenced
this issue
May 16, 2018
4 tasks
fersarr
pushed a commit
to fersarr/pandas
that referenced
this issue
May 22, 2018
fersarr
pushed a commit
to fersarr/pandas
that referenced
this issue
May 23, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Calling
to_records()
on an empty dataframe after a group-by results in aValueError
:Problem description
Calling
to_records()
on an empty dataframe after a group-by results in aValueError
. I expect this to not throw and return the records.The same code above without column 'C' (using 2 columns) works fine.
The problem is here:
https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1419
where
names
andformats
have different lengths and makenumpy
upset.This seems to work in pandas==0.16.2 and returns the following
The text was updated successfully, but these errors were encountered: