Answers for "string methods to clean column dataframe"

0

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)
Posted by: Guest on July-25-2021

Code answers related to "string methods to clean column dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language