Current Answer (Pandas> = 0.13)
Pandas 0.13 . Pandas Series , Python:
class MySeries(pd.Series):
def my_method(self):
return "my_method"
Legacy Answer (Pandas <= 0,12)
, Series __new__, Series.
:
class Support(pd.Series):
def __new__(cls, *args, **kwargs):
arr = Series.__new__(cls, *args, **kwargs)
return arr.view(Support)
def supportMethod1(self):
print 'I am support method 1'
def supportMethod2(self):
print 'I am support method 2'
, , a-a a-a. Series. , Pandas - . - ,
s.ix[:5]
s.cumsum()
Series . . , , . , , - s.ix[:5] . , .
http://nbviewer.ipython.org/3366583/subclassing%20pandas%20objects.ipynb .