chris1610 / sidetable

sidetable builds simple but useful summary tables of your data
https://pbpython.com
MIT License
385 stars 29 forks source link

Feature Request: upper case column names for stb.freq #10

Closed discdiver closed 3 years ago

discdiver commented 4 years ago

Great package! Thank you for it.

stb.freq() returns a DataFrame with Count, Percent, Cumulative Count, and Cumulative Percent columns in title case. The original column that is also in the resulting DataFrame is often in snake case. Screen Shot 2020-06-24 at 11 06 37 AM

The user can manually use .rename to make the formatting match, but sidetable is all about nicely displayed summary tables. Is it worth having a separate argument to stb.freq() to make the column name formatting match? Or is it worth including it as part of (style=True)?

chris1610 commented 4 years ago

Interesting idea. I wonder how hard it is to infer/check column naming style based on the other columns. Do you have any thoughts on that aspect? I like the idea of making this part of style=True because I think consistency is good and using styling to modify might be more expected.

discdiver commented 4 years ago

I don't think I would infer. I would probably just leave it at changing snake case to title with spaces. Maybe do the same for dashes.

You could do with with regex, or chained str.replaces like this:

df.columns.str.replace('_', ' ').str.replace('-', ' ').str.title()