Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add .dt.total_seconds() method for timedelta64 Series #10817
Background: I am trying to build a horizonal bar graph that shows me when various builds on a server started and ended, so that I can see visually which builds overlapped in time. But the idea that a horizontal bar graph's bar-width would be a timedelta seems completely foreign to all of the plotting libraries that I have tried today (matplotlib, bokeh, ggplot), so I want to punt and instead reduce my timedelta64's to a floating-point number of days. I can then fudge the axes to display dates anyway.
Problem: there is no easy way to move from a timedelta64 to the standard Python idea of an ordinal date. I would have to extract all of the components manually (days, seconds, fractions of a second) and then multiply them each by an appropriate factor and then add them back together.
This is not a perfect solution, since the factors it uses internally neglect the fact that a day might have included a leap second, but it works pretty well for non-astronomical use.
canoncially this is just an astype or division operation
I suppose could add a