question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Aliases for column names

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:32
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
KeithWMcommented, Sep 14, 2018

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.

4reactions
ajeet2808commented, Apr 27, 2020

Any update on this feature?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found