string methods to clean column dataframe

Solutions on MaxInterview for string methods to clean column dataframe by the best coders in the world

showing results for - "string methods to clean column dataframe"
Victor
16 Aug 2019
1def clean_col(col):
2    col = col.strip()
3    col = col.replace("(","")
4    col = col.replace(")","")
5    col = col.lower()
6    return col
7
8new_columns = []
9for c in df.columns:
10    clean_c = clean_col(c)
11    new_columns.append(clean_c)
12
13df.columns = new_columns
14print(df.columns)