Change Data Type for one or more columns in Pandas Dataframe

Change Data Type for one or more columns in Pandas Dataframe

 

In this article, you will learn how to changing Data Type for one or more columns in Pandas Dataframe.

 

import pandas as uc

d = uc.DataFrame({ 
	'A': [1, 2, 3, 4, 5, 6], 
	'B': ['a', 'b', 'c', 'd', 'e', 'f'], 
	'C': [1.1, '1.0', '1.3', 2, 5, 10] }) 

# converting all columns to string type 
d = d.astype(str) 
print(d.dtypes) 

2021-10-03