Skip to content
Advertisement

Tag: timedelta

How to datetime parse a non-standardized time format

I would like to create datetime objects from a list of string timecodes like these. However, parse interprets incorrectly for my use case. The list above comes from YouTube’s transcript timecodes. When copied from the site, they use a variable format to designate hours, minutes, and time, based on elapsed time: and parse results in (comments are my interpretations): i.e.

Is there a bug in Python 3.8 datetime with DST transitions?

I’m trying to convert a timezone-aware datetime in Europe/Sofia to the start of the day in Europe/Sofia, but returning the datetime in UTC. Doing this, I encountered a strange problem: Which prints: The bug happens when subtracting the timedelta or doing the replace(), because the result should be midnight in Europe/Sofia with +2 offset, however we’re seeing an incorrect +3

Add timedelta to a date column above weeks

How would I add 1 year to a column? I’ve tried using map and apply but I failed miserably. I also wonder why pl.date() accepts integers while it advertises that it only accepts str or pli.Expr. A small hack workaround is: but this won’t work for months or days. I can’t just add a number or I’ll get a: Most

How to get grouped cumulative duration in pandas?

I have the following data: id encounter_key datetime 1 111 2019-04-14 1 111 2019-04-14 1 111 2019-07-18 1 122 2019-09-02 2 211 2019-10-03 2 211 2020-10-03 I want to find the cumulative duration, grouped by id and encounter_key to achieve the following: id encounter_key datetime cum_duration_days 1 111 2019-04-14 0 1 111 2019-04-14 0 1 111 2019-07-18 95 1 122

python convert timedelta to meaningful string such as “1 hours”

I want to convert a python timedelta object to an easy to read meaningful string for example: any ideas how to do that? Thanks Answer Actually timedelta class, provides you days, seconds, microseconds property directly. But in order to get “hours” and “minutes” you can do some simple calculations yourself. Divide seconds by 60 to get minutes, by 3600 to

Advertisement