I load a csv in a pandas dataframe (one column is full of datime values):
def edit(filename):
df = pd.read_csv ( filename, sep=';',decimal=',', skiprows=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], error_bad_lines=False )
df = df[['TimeString','VarValue']]
df['TimeString'] = pd.to_datetime(df['TimeString'], format='%d/%m/%Y %H:%M:%S')
df['VarValue'] = pd.to_numeric(df['VarValue'])
return df
I draw a plot with plot_date:
def plotting(self, df):
self.axes.grid(True)
self.axes.plot_date(df['TimeString'], df['VarValue'],'-',label='MACD_14_21')
self.axes.legend(loc='upper left')
self.canvas.draw()
Now I would like to use the function:
def onMouseMove(self, event):
print(event.xdata, event.ydata)
cid = self.canvas.mpl_connect('motion_notify_event', self.onMouseMove)
What I get is:
737235.953598 91.53
So The event.ydata works fine, but the event.xdata instead of give me a datetime values is giving me a unknown float64. But in the meanwhile the GUI inferface is going to get the correct X data value:
So, How can I get the right datetime value? Or how can I convert the float value in a datetime value?
Thank you so much for your help
Luca
PS: all the tutorials shown the possibility to use the normal plot with datetime values too but when I use it with so many data (>20k) the plotting is very slow.