Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

change all columns in dataframe to string

for colname in df.columns:
            try:
                df[colname] = df[colname].astype('str')
                print(f"{colname} converted")
            except ValueError:
                print(f"{colname} failed")
 
PREVIOUS NEXT
Tagged: #change #columns #dataframe #string
ADD COMMENT
Topic
Name
3+1 =