1,390 questions
4
votes
1
answer
139
views
Python datetime and timedelta behaviour over Daylight savings time change
I encountered this behaviour and I figured I would ask the correct way to go about it.
Here is a toy example:
pre_timechange = datetime.datetime(2025, 11, 2, 1, 59, 9, tzinfo=zoneinfo.ZoneInfo(key='...
-2
votes
1
answer
66
views
Timedelta Unit Argument as a Variable [duplicate]
Is it possible to have the units argument for the timedelta function be defined by a variable?
To elaborate, is this possible?
Time_Unit = "days"
Time_Increment = 1
Time2 = Time1 + ...
1
vote
2
answers
186
views
How do you efficiently find gaps in one list of datetimes relative to another?
I have datasets from multiple instruments with differing, but hypothetically concurrent datetime stamps. If date from instrument A does not correspond to any data from instrument B within some ...
1
vote
2
answers
79
views
numpy timedelta highest unit without loss of information
I have several numpy timedelta values.
I want to convert them to the a format that is better to read for humans without losing information.
Let's say I have td = np.timedelta64(10800000000001, 'ns').
...
0
votes
0
answers
97
views
pyqtgraph: Show x axis labels in the form DD HH:MM:SS of data representing timedeltas with DateAxisItem
I am trying to use pyqtgraphs DateAxisItem for relative times on the x axis, i.e., durations (which can be between a few hours and several days). I know I could simply use an ordinary AxisItem and ...
0
votes
2
answers
474
views
Databricks DeltaLake : Cannot time travel Delta table to version 1. Available versions: [3, 23]
I have been using the following code to determine the latest table using Databricks TimeTravel feature for the past few years without any issues. I recently added a new row to the table that I have ...
0
votes
1
answer
87
views
How can I run a code where I can plot and save multiple hours of the latest GFS model run?
I want to plot precip type from the start of the GFS run (hour 0) through hour 240 at 6-hour intervals. (in this code I only try to go to hour 108) Also, at the end of the code when saving the the ...
3
votes
2
answers
204
views
Convert a Polars duration type into a human-readable string
When printing a polars data frame, pl.Duration are printed in a "human format" by default. What function is used to do this conversion? Is it possible to use it? Trying "{}".format(...
2
votes
2
answers
214
views
Do I need to use timezones with timedelta and datetime.now?
If I only use datetime.now() with timedelta to calculate deltas, is it safe to ignore time zones? For example, is there a case where if a start time is before daylight savings, and an end time is ...
1
vote
0
answers
29
views
Is there a way to represent time deltas in Python that differentiates between "1 day" and "24 hours"? [duplicate]
I'm currently working on a reminder bot project that supports recurring reminders. For example, a user can specify that they want their reminder to repeat in intervals of "3 days", "12 ...
1
vote
1
answer
83
views
How to substract amount of minutes in Pandas DataFrame datetime with condition?
I have a DataFrame like this (date: datetime64[ns], v: float64)
date v
2024-09-01 22:09:55 1.2
2024-09-01 22:12:08 1.11
2024-09-01 22:59:59 1.7
2024-09-01 23:00:02 1.1
...
-1
votes
1
answer
64
views
Unix timestamp +1 hour replacement
I defined two helper methods in Python for setting start-time and end-time and want it converted into unix timestamp (epoch):
def set_epoch_start():
unix_epoch = datetime.utcfromtimestamp(0)....
3
votes
0
answers
1k
views
How to fix "Please use 'min' instead of 'T'" [closed]
How can I fix the warning:
FutureWarning: 'T' is deprecated and will be removed in a future version. Please use 'min' instead of 'T'.
if median_diff > pd.Timedelta(freq):
In the method below it ...
0
votes
1
answer
95
views
JavaScript game running extra fast on newer MacBook
So I made a JavaScript clone of Flappy Bird. It runs beautifully on my 2021 M1 iMac, almost perfect...
It also runs fairly well on my 2023 M2 MacBook Pro, minus some minor glitches. HOWEVER, this is ...
2
votes
1
answer
82
views
How to convert timedelta to integer in pandas dataframe
I am trying to convert timedelta to integer.
time = (pd.to_datetime(each_date2)-pd.to_datetime(each_date1))
pd.to_numeric(time, downcast='integer')
time has following value:
Timedelta('7 days 00:00:...