Skip to content

Aliases for column names #11723

@bbirand

Description

@bbirand

When I work with Pandas DataFrames, I prefer to keep the full column names for clarity. So when I print out the head, or use describe, I get a meaningful table. However, this also means I have column names like "Time of Sale" that become annoying to type out.

A nice compromise seems like it would be to have short "aliases" for column names. For instance, I can define the tos average for the above, perhaps like so:

df = pd.read_csv(...)
df.set_alias({'Time of Sale' : 'tos'})

Then, the __get_attribute__ method can look up aliases in addition to column names, so I can refer to that column simply as df.tos. But for all other purposes, the columns name is still the descriptive full name.

Would this make sense?

Metadata

Metadata

Assignees

Labels

EnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesNeeds DiscussionRequires discussion from core team before further action

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions