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

BUG: DataFrame doesn't hold _metadata when sliced by slice instance #9776

Closed
sinhrks opened this issue Apr 1, 2015 · 2 comments · Fixed by #9793
Closed

BUG: DataFrame doesn't hold _metadata when sliced by slice instance #9776

sinhrks opened this issue Apr 1, 2015 · 2 comments · Fixed by #9793
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented Apr 1, 2015

import pandas as pd


class TestDataFrame(pd.DataFrame):

    _metadata = ['testattr']

    @property
    def _constructor(self):
        return TestDataFrame

df = TestDataFrame({0: [1, 2, 3], 1: [1, 2, 3]})
df.testattr = 'XXX'
df.testattr
# XXX

# Using list is OK
df.iloc[[0, 1], :].testattr
# XXX

# Using slice is NG
df.iloc[0:1, :].testattr
# AttributeError: 'TestDataFrame' object has no attribute 'testattr'
@jreback
Copy link
Contributor

jreback commented Apr 1, 2015

should prob work though vey few tests ATM for using _metadata at all (it's not really a user feature)

@sinhrks
Copy link
Member Author

sinhrks commented Apr 1, 2015

Understood. Because I'm trying to subclass DataFrame, I'll dig in when I have a time.

@jreback jreback added this to the Next Major Release milestone Apr 2, 2015
@jreback jreback modified the milestones: 0.16.1, Next Major Release Apr 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants