Skip to content

BUG: _metadata does not persist through groupby #38269

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
2 of 3 tasks
stuart23 opened this issue Dec 3, 2020 · 2 comments
Closed
2 of 3 tasks

BUG: _metadata does not persist through groupby #38269

stuart23 opened this issue Dec 3, 2020 · 2 comments
Labels

Comments

@stuart23
Copy link

stuart23 commented Dec 3, 2020

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


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

class MyDataFrame(DataFrame):
    _metadata = ['my_metadata']

data = MyDataFrame({'test': [1,1,1,2,2,2]})
data.my_metadata = 2
for group_id, group_data in data.groupby('test'):
    assert group_data.my_metadata == 2

Problem description

As per documentation here, it seems that any derivatives of a DataFrame should inherit the metadata properties assigned. This is true with slicing operations, but is not true with groupby(). It would be more consistent if the property persisted for slicing and groupby().

Expected Output

Should not raise an assertion error.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 67a3d42
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-56-generic
Version : #62-Ubuntu SMP Mon Nov 23 19:20:19 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.4
numpy : 1.19.4
pytz : 2019.3
dateutil : 2.7.3
pip : 20.0.2
setuptools : 45.2.0
Cython : 0.29.21
pytest : 6.1.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.4
sqlalchemy : None
tables : None
tabulate : 0.8.6
xarray : 0.14.1
xlrd : None
xlwt : None
numba : 0.51.2

@stuart23 stuart23 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 3, 2020
@stuart23
Copy link
Author

stuart23 commented Dec 8, 2020

Can close. Looks like it was fixed by #37343

@arw2019
Copy link
Member

arw2019 commented Dec 9, 2020

Can close. Looks like it was fixed by #37343

Right. Thanks for reporting and follow-up

@arw2019 arw2019 closed this as completed Dec 9, 2020
@simonjayhawkins simonjayhawkins removed the Needs Triage Issue that has not been reviewed by a pandas team member label Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants