Aliases for column names
See original GitHub issueWhen 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?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:32
- Comments:12 (4 by maintainers)
Top Results From Across the Web
SQL Aliases - W3Schools
SQL aliases are used to give a table, or a column in a table, a temporary name. Aliases are often used to make...
Read more >SQL: ALIASES - TechOnTheNet
This SQL tutorial explains how to use SQL ALIASES (temporary names for columns or tables) with syntax and examples. SQL ALIASES can be...
Read more >SQL - Alias Syntax - Tutorialspoint
SQL - Alias Syntax, You can rename a table or a column temporarily by giving another name known as Alias. The use of...
Read more >SQL alias: Make Your Query Shorter And More Understandable
SQL alias allows you to assign a table or a column a temporary name during the execution of a query. SQL has two...
Read more >How to Use Aliases in SQL Queries - LearnSQL.com
You can temporarily rename a table or a column by giving it another name. This is known as an SQL alias. It's a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d also like to see such a feature. For me the favourite use case would be to have nice, legible axes labels (with units) in seaborn plots. I know one can manually set the axis labels, but I find this error prone, too verbose and it leads to code duplication.
If you ask me, the easier way would be to keep the current name in the role of an alias as @bbirand proposes, and to add some other field for a longer name, which can default to the “normal” name if none is explicitly given.
Any update on this feature?