A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/9776 below:

DataFrame doesn't hold _metadata when sliced by slice instance · Issue #9776 · pandas-dev/pandas · GitHub

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'

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4