I have a pandas data frame with datetime values:
Date/Time Event Value
0 2018-11-15 17:17:49 62
1 2018-11-15 17:27:50 63
2 2018-11-15 17:37:5
If you plot a dataframe with the x_compat=True
option you can be certain that the units are matplotlib.dates units. Else, pandas may decide some units for you.
Here, pandas uses matplotlib dates units. They are defined as:
Matplotlib represents dates using floating point numbers specifying the number of days since 0001-01-01 UTC, plus 1. For example, 0001-01-01, 06:00 is 1.25, not 0.25. Values < 1, i.e. dates before 0001-01-01 UTC are not supported.
You are however not expected to calculate those units yourself. Matplotlib provides helper functions
matplotlib.dates.date2num
matplotlib.dates.num2date
matplotlib.dates.datestr2num
which you can use to calculate back and forth between the units.
As an example, matplotlib.dates.datestr2num("2018-11-15 19:27:48")
gives you 737013.8109722222
.