How to fix this Inferring datetime64[ns] error?

16 views Asked by At

I have the following code which worked fine:


import pandas as pd
import datetime as datetime
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.nonparametric.smoothers_lowess import lowess

df2= pd.read_excel(open('C:/Users/atene/Programas anaconda/Glicemias/Copia de Glycemia Andrés Valenzuela.xlsx','rb'))
print (df2)  

df = pd.DataFrame(df2) 
df['Time'] = df['Device Timestamp']
df['Glucose'] = pd.to_numeric(df['Historic Glucose mg/dL'])
df.drop(df.index[:12], inplace=True)
df['Time'] =  pd.to_datetime(df['Time'], format='%Y-%m-%dT%H:%M:%S')
df['Day'] = df['Time'].dt.date
df = df.reset_index()
print (df)

But now I'm getting the following warning:

C:\Users\atene\Programas anaconda\Glicemias\intento 3.py:14: FutureWarning: Inferring datetime64[ns] from data containing strings is deprecated and will be removed in a future version. To retain the old behavior explicitly pass Series(data, dtype=datetime64[ns]) df2= pd.read_excel(open('C:/Users/atene/Programas anaconda/Glicemias/Copia de Glycemia Andrés Valenzuela.xlsx','rb'))

I'm new to python so I don't know what to do.

i have python 3.9

I don't know what to do

0

There are 0 answers