Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Possibly related to:
Code Sample, a copy-pastable example
df = pandas.DataFrame({"a": [1]})
df.a.attrs = {"test": "test"}
df2 = df.copy() # same behavior for df.reset_index()
df2.a.attrs
{}
df.a.attrs
{}
Problem description
Ideally, when making a copy, the attributes will be preserved on both dataframes.
Expected Output
df2.a.attrs
{"test": "test"}
df.a.attrs
{"test": "test"}
Output of pd.show_versions()
INSTALLED VERSIONS
commit : 1963b81
python : 3.7.9.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-73-generic
Version : #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.0.dev0+1660.g1963b810b3
numpy : 1.20.1
pytz : 2020.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 49.1.0
Cython : 0.29.23
pytest : 6.2.2
hypothesis : 6.13.0
sphinx : 3.5.4
blosc : 1.10.2
feather : None
xlsxwriter : 1.4.3
lxml.etree : 4.6.2
html5lib : 1.1
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.11.3
IPython : 7.20.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 2021.05.0
fastparquet : 0.6.3
gcsfs : 2021.05.0
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : 4.0.0
pyxlsb : None
s3fs : 2021.05.0
scipy : 1.6.0
sqlalchemy : 1.3.23
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.17.1.dev149+g49aa235f.d20210518
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.53.1