Created
December 6, 2024 11:46
-
-
Save andrewmoles2/1caedef434b2353ad4639527fb1ee75c to your computer and use it in GitHub Desktop.
Janitor clean names in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clean_names(cols): | |
current_cols = cols | |
new_cols = [] | |
for c in range(0, len(current_cols)): | |
new_cols.append( | |
current_cols[c].lower().replace(' ', '_').replace('(', '').replace(')', '') | |
) | |
return(new_cols) | |
# we use the .columns method to access the column names | |
# this applies to both polars and pandas | |
#df.columns = clean_names(df.columns) | |
#print(df.head()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment