I have
class MySeries(pd.Series):
_metadata = [_md]
def __init__(self, *args, **kwargs):
md = kwargs.pop('md', None) #md is series
super(TimeSeries, self).__init__(*args, **kwargs)
if md is not None:
try:
self._md = self._md.append(md)
except AttributeError:
self._md = md
@property
def _constructor(self):
return MySeries
class MyFrame(pd.DataFrame):
@property
def _constructor(self):
return MyFrame
@property
def _constructor_sliced(self):
return MySeries
md_a = pd.Series(...some content...)
md_b = pd.Series(...some other content...)
a = MySeries(...some a content..., md=md_a)
b = MySeries(...some b content..., md=md_b)
Tim now everything is fine: a._md gives the content of md_a. So does b.
No I create my MyFrame with :
f = MyFrame([a,b]).T
or
f = SecuritiesFrame()
f = pd.concat((f, a, b), axis=1)
Now I try to get the metadata:
f.iloc[:,1]._md
I get an AttributeError: 'MyFrame' object has no attribute '_md' as the metadata is not propagated.
Is this a normal behavior or am I overseeing something? Do I have to track the metadata myself separately in my subclass of DataFrame which would be very inconvenient.