0

Need to convert pandas dataframe columsn from float64 to object datatype with mentioning the column name.

Input Data

customer_number|email_type|email|phone_type|phone
123|ABC|Primary|abc.def@dd.edu|Mobile|+12345678

Data type :

Customer_number       int64
first_name           object
email_type           object
email                object
phone_type           object
phone               float64

Expected Output Data type

Data type :
Customer_number       int64
first_name           object
email_type           object
email                object
phone_type           object
phone                object

Code

df = pd.read_csv("filename.csv",sep="|")
df['phone'] = df['phone'].astype(str).str.replace('\.0', '')

I don't want to mentioned columns name in code. It should be work for all the columns which has float64 datatype.

0 Answers0