Skip to content
Advertisement

Tag: timedelta

Convert result of sum of timedeltas in Python

I have the output below from a sum of a timedelta list in a column on my dataframe. How do I get values converted to hours minutes and total seconds? Answer afaik, there’s no built-in functionality for this. But you can create your own. For example for formatting to a string in H:M:S format or splitting the timedelta into separate

timedelta error with numpy.longdouble dtype

I have times with dtype numpy.longdouble and when I’m trying to use that values with timedelta function I’ve got errors. But when I convert it to numpy.float64 everything is fine. Could somebody explain that behaviour? When I’m trying to see dtypes of variables they are look the similar but not the same: Edit And it’s strange that it’s not working

How can I make a python numpy arange of datetime

I have some input data, with timestamps in the input file in the form of hours from the date time specified in the filename. This is a bit useless, so I need to convert it to python datetime.datetime objects, and then put it in a numpy array. I could write a for loop, but I’d like to do something like:

How to construct a timedelta object from a simple string

I’m writing a function that needs to parse string to a timedelta. The user must enter something like “32m” or “2h32m”, or even “4:13” or “5hr34m56s”… Is there a library or something that has this sort of thing already implemented? Answer For the first format (5hr34m56s), you should parse using regular expressions Here is re-based solution:

Advertisement