See SO post https://stackoverflow.com/q/46498784/2336654
Code Sample, a copy-pastable example if possible
from pandas import Series
class Xseries(Series):
_metadata = ['attr']
@property
def _constructor(self):
return Xseries
def __init__(self, *args, **kwargs):
self.attr = kwargs.pop('attr', 0)
super().__init__(*args, **kwargs)
s = Xseries([1, 2, 3], attr=3)
Problem description
According to https://pandas.pydata.org/pandas-docs/stable/internals.html#define-original-properties
I should be able to define an original property and have it passed on when a new object is constructed.
This works
s.mul(2).attr
3
While this doesn't
s.__mul__(2).attr
0
Expected Output
I expected both output to be 3
Output of pd.show_versions()
[paste the output of ``pd.show_versions()`` here below this line]
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.20.3
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.3.0
Cython: 0.25.2
numpy: 1.13.1
scipy: 0.18.1
xarray: 0.9.5
IPython: 6.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.1
feather: 0.4.0
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: 0.999999999
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: 0.4.0
Comment From: chris-b1
Duplicate of #13208 - PR to address welcome