0

I want to import an excel file into pandas. It has a column with dates, but when I import it, its type is numpy float64. I obtain the following dataframe (first row):

totales.iloc[0]

returns

Fecha              44767.0
Monto                207.5
Otros    De Souza 2 fletes
Name: 0, dtype: object

The dtype of the value:

type(totales.iloc[0]["Fecha"])

returns:

numpy.float64

I have tried a lot of alternatives for instance:

totales["Fecha"]= totales["Fecha"].astype(str).astype("datetime64")
totales.iloc[0]["Fecha"]

returns

1970-01-01 00:00:00.000044767   

44767.0 is the non converted value as shown. I have also tried:

totales['Fecha'] = pd.to_datetime(totales['Fecha'], unit="s")
totales.head(1)

that returns:

Fecha         1970-01-01 12:26:07
Monto                       207.5
Otros           De Souza 2 fletes

I again obtain a date that is not the right one. I have also tried other proposals unsuccesfully. I will appreciate any solution to this problem

Hermes Morales
  • 593
  • 6
  • 17

0 Answers0