Skip to content

BUG: No longer possible to assign attrs to pandas column #64711

@sursu

Description

@sursu

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
df.attrs = {"A": [10, 20, 30]}
df['A'].attrs['info'] = 'Antofagasta'
df['A'].attrs

Issue Description

While it is possible to assign metadata to dataframes, it appears that it is no longer possible to assign metadata to columns.

The column will simply inherit the attrs of the dataframe.

The good part is that the attrs of the dataframe seem to remain in place after modifying it (e.g. by dropping rows), which didn't hold in version 2.3.3 for instance.


I wanted to look through the code, but it appears that [source] on the pandas.DataFrame.attrs page points to a non-existing location.

Expected Behavior

The output of df['A'].attrs from above should be {'info': 'Antofagasta'}. And this information should remain when the dataframe is modified, e.g. when rows or other columns are dropped, when the index is changed, when another dataframe is merged into the current one, etc.

Installed Versions

Details commit : e04b26f python : 3.13.5 python-bits : 64 OS : Linux OS-release : 5.14.0-611.30.1.el9_7.x86_64 Version : #1 SMP PREEMPT_DYNAMIC Wed Feb 11 06:42:00 EST 2026 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 3.0.1
numpy : 2.3.2
dateutil : 2.9.0.post0
pip : 25.1
Cython : None
sphinx : None
IPython : 9.5.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.5
bottleneck : None
fastparquet : None
fsspec : None
html5lib : 1.1
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : 6.0.2
matplotlib : 3.10.6
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
psycopg2 : None
pymysql : None
pyarrow : None
pyiceberg : None
pyreadstat : None
pytest : 9.0.2
python-calamine : None
pytz : 2025.2
pyxlsb : None
s3fs : None
scipy : 1.17.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.2
xlsxwriter : None
zstandard : 0.23.0
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions