Skip to content

ENH: Preserve column attrs when doing column selection #55552

Open
@kerrickstaley

Description

@kerrickstaley

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

It would be nice if, when doing column selection on a dataframe, the attrs of the individual series were preserved.

Specifically, this code:

import pandas as pd
df = pd.DataFrame({'a': [1, 2]})
df['a'].attrs['foo'] = 'bar'
print(df[['a']]['a'].attrs)

currently prints

{}

but I would like it to print

{'foo': 'bar'}

Feature Description

N/A

Alternative Solutions

N/A

Additional Context

No response

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