I created a .csv
file from a dataframe as below:
df.to_csv('partial.csv', sep=',')
Datatypes in the dataframe
df.dtypes
gives:
Contact_ID int64
Src_Sys_Cd object
First_Name object
Last_Name object
Src_Sys_Key object
Full_Name object
Office_No object
Mobile object
Email object
dtype: object
When I try to read the newly created .csv
file using read_csv
it gives me error:
new_df = pd.read_csv('partial.csv')
DtypeWarning: Columns (5) have mixed types. Specify dtype option on import or set low_memory=False. interactivity=interactivity, compiler=compiler, result=result)
How can I avoid this error? Is this error coming up because I did something wrong while to_csv
or read_csv
?