Home > Mobile >  How do I convert unusual time string into date time
How do I convert unusual time string into date time

Time:09-03

I measured the seeing index and I need to plot it as a function of time, but the time I received from the measurement is a string with 02-09-2022_time_11-53-51,045 format. How can I convert it into something Python could read and I could use in my plot?

Using pandas I extracted time and seeing_index columns from the txt file received by the measurement. Python correctly plotted seeing index values on Y axes, but besides plotting time values on the X axis, it just added a number to each row and plotted index against row number. What can I do so it was index against time?

enter image description here

CodePudding user response:

You may try this:

df.time = pd.to_datetime(df.time, format='%d-%m-%Y_time_%H-%M-%S,%f')
  • Related