I am loading the table into pandas as follows:
import pandas as pd
df=pd.read_excel(file.xlsx,dtype=object)
A B C D
1 2.0 1-02-1997 sam
Nan 2.3 3-08-1997 ram
2 nan 2-03-1997 pam
then I am replacing NaN Value
df=df.fillna(method='ffill')
then I am converting columns to int and float using
for c in df.columns:
df[c]=pd.to_numeric(df[c],error='ignore')
but this will convert datetime columns also into the int/float
.
Is there any way to restrict datetime conversion to int/float
?