string methods to clean column dataframe
def clean_col(col):
col = col.strip()
col = col.replace("(","")
col = col.replace(")","")
col = col.lower()
return col
new_columns = []
for c in df.columns:
clean_c = clean_col(c)
new_columns.append(clean_c)
df.columns = new_columns
print(df.columns)
Are there any code examples left?
New code examples in category Python