The Scenario
I have 2 CSV files (1) u.Data and (2) prediction_matrix which I need to read and write into a Single Dataframe, once done it is processed for Clustering based on int / float values it will contain
The Problem
I'm done combining the 2 CSVs into 1 Dataframe named AllData.csv, but the type of columns holding value have a different type now (object), as shown below (with a warning)
sys:1: DtypeWarning: Columns (0,1,2) have mixed types. Specify dtype option on import or set low_memory=False.
UDATA -------------
uid int64
iid int64
rat int64
dtype: object
PRED_MATRIX -------
uid int64
iid int64
rat float64
dtype: object
AllDATA -----------
uid object
iid object
rat object
dtype: object
P.S. I know how to use low_memory=False
and that just supresses the warning.
The Possible Cause
with open('AllData.csv', 'w') as handle:
udata_df.to_csv(handle, index=False)
pred_matrix.to_csv(handle, index=False)
Since, I need to write 2 CSVs into Single DF handle object is used and probably that turns all the values into its type. Can anything preserve the data type applying the same logic?
Unhelpful References taken so far: