Search
 
SCRIPT & CODE EXAMPLE
 

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")
Comment

PREVIOUS NEXT
Code Example
Python :: fstring number format python 
Python :: sum of 1 to n number in python 
Python :: select columns from dataframe pandas 
Python :: how to code in python 
Python :: python for loop backwards 
Python :: apply strip() a column in pandas 
Python :: max of 2d array python 
Python :: python remove stop words 
Python :: md5 hash python 
Python :: how to add special token to bert tokenizer 
Python :: docker pyinstaller windowa 
Python :: pandas scatter plot with different colors 
Python :: add static file in django 
Python :: python download file from web 
Python :: ec2 upgrade python 3.7 to 3.8 
Python :: python hello wrold 
Python :: django print settings 
Python :: python temporary files 
Python :: skip rows in pandas read excel 
Python :: number 1 
Python :: knn classifier python example 
Python :: plot python x axis range 
Python :: pandas correlation 
Python :: python merge csv files in same folder 
Python :: how to check python version in cmd 
Python :: add time delta pytohn 
Python :: multiply column of dataframe by number 
Python :: convert excel to csv using python 
Python :: virtual environment flask 
Python :: how to find duplicate numbers in list in python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =