-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: groupby __iter__ on pandas 1.1.x not propagating _metadata on DataFrame subclasses #37343
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
Comments
related comment and existing possible fix: #28283 (comment) |
Thanks for the report! |
I don't think it was fixed there. I think #37461 is on the right track - I have tracked our specific issue to in FrameSplitter._chop: modifying: def _chop(self, sdata: DataFrame, slice_obj: slice) -> DataFrame:
# Fastpath equivalent to:
# if self.axis == 0:
# return sdata.iloc[slice_obj]
# else:
# return sdata.iloc[:, slice_obj]
mgr = sdata._mgr.get_slice(slice_obj, axis=1 - self.axis)
return type(sdata)(mgr) to def _chop(self, sdata: DataFrame, slice_obj: slice) -> DataFrame:
# Fastpath equivalent to:
# if self.axis == 0:
# return sdata.iloc[slice_obj]
# else:
# return sdata.iloc[:, slice_obj]
mgr = sdata._mgr.get_slice(slice_obj, axis=1 - self.axis)
return type(sdata)(mgr).__finalize__(sdata) Propogates the metdata, but as I understand it there are places to and to not use |
the code sample passes with that PR in it's current state. I'll comment there about adding a test for this issue. However, that PR still needs review and 1.1.4 is scheduled for tomorrow, so moving off 1.1.4 milestone for now. |
first bad commit: [6f065b6] PERF: faster indexing for non-fastpath groupby ops (#34214) cc @jbrockmendel |
I hope so -- my own code broke on the 1.1 update as well :) |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
Under pandas 1.0.x the above is working, on 1.1.x, the _metadata is not propagated to the split frames. I think this is a known issue with groupby and
__finalize__
, but this specific behavior with__iter__
is a regression from 1.0.x behavior on DataFrame subclasses.Expected Output
Assert statements above are passing, with metadata propagated to the split dataframe
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : db08276
python : 3.7.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.1.3
numpy : 1.18.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.1.3.post20200330
Cython : 0.29.17
pytest : 5.4.1
hypothesis : 5.36.1
sphinx : 2.4.4
blosc : None
feather : None
xlsxwriter : 1.2.8
lxml.etree : 4.5.0
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.13.0
pandas_datareader: None
bs4 : 4.9.0
bottleneck : 1.3.2
fsspec : 0.8.0
fastparquet : None
gcsfs : None
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.16
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.49.0
The text was updated successfully, but these errors were encountered: