1,391 questions
4
votes
1
answer
128
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='...
1
vote
2
answers
170
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 ...
0
votes
0
answers
83
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
1
answer
83
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 ...
2
votes
2
answers
203
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
1
answer
76
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
...
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 ...
2
votes
1
answer
80
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:...
0
votes
1
answer
51
views
Fill rows based on start vs end date in Pandas, including start date
I currently have an issue of spanning rows given by a start vs end date range in Pandas, but need to bring the start date as well, not only the difference.
I tried this solution link.
Credits to @...
0
votes
1
answer
72
views
Python Pandas df, subtract minutes (in time duration column) from time column
I have a pandas df with Time, Duration (in minutes, integer format), and Duration in timedelta format. The EndTime column has been parsed to time format.
id
EndTime
Duration_Minutes
Duration_TimeDelta
...
0
votes
2
answers
48
views
Pandas, find difference between two columns, each having different datatype values
consider following input data
prod
col1
col2
One
hi
hello
One
18.0
19.52
One
2024-02-12 00:00:00
2024-03-07 00:00:00
two
2024-02-12 00:00:00
2024-02-11 00:00:00
two
in-transit
in-stock
want to find ...
1
vote
1
answer
55
views
having trouble with calculating previous close for tr calculations
im trying troubleshoot and understand why the first day[2024-03-27], is printing values for tr2 and tr3 when it should be printing nan nan because there is not previous day for 2024-03-27
i only ...
1
vote
2
answers
108
views
How to convert timedelta in data frame to datetime
I have couple columns in df with avg time, example "0 days 00:00:21". I want convert all columns to datetime.time format "hh:mm:ss" without "0 days". How can I do this?
...
0
votes
1
answer
41
views
How to change `Vector2` 's values in the virtual `render(delta:Float)` method of the Screen interface of com.badlogic.Gdx
Currently, when the Vector2's instance value is modified either using *= operator in that method,
for the first iteration of when the function is being called, it correctly change the value to the ...
0
votes
1
answer
635
views
Python pandas : add one hour to a Dataframe column containing dates
I am new at python.
I have a df called dates which is storing dates. I want to add an extra hour to the whole column.
0 2011-01-07
1 2011-01-07
2 2011-01-10
3 2011-01-10
4 ...
0
votes
1
answer
526
views
I want to implement the Gold layer in the synapse delta lake how to do that
WE have implemented the Synapse with delta lake mechanism till silver i want to implement gold layer now dont understand how to do it we are using Azure server less sql
how the gold layer model and ...
2
votes
2
answers
116
views
How to print timedelta consistently (i.e. formatted)
I have this code that prints the time difference in milliseconds.
#!/usr/bin/python
import datetime
import sys
date1= datetime.datetime.strptime('20231107-08:52:53.539', '%Y%m%d-%H:%M:%S.%f')
date2= ...
0
votes
1
answer
165
views
python datetime delta inaccuracy - Sidereal period
In python datatime module I noticed a gap. Datetime does leap year adjustment automatically, using sidereal year length.
How to achieve scientific accuracy in these date calculations?
The difference ...
0
votes
2
answers
78
views
Python Covert Duration String to Number Format in Hours
I have a Pandas dataframe with a Duration column with contains durations as text with the following format. Some strings have "Days" added at the beginning where some of them just have the ...
3
votes
3
answers
694
views
Convert a Pandas Series from Timedelta to Microseconds
I have a Pandas Timedelta column that may be created like this:
import pandas as pd
tdelta_ser = pd.date_range(start='00:00:00', periods=3, freq='700ms') - pd.date_range(start='00:00:00', periods=3, ...
2
votes
2
answers
2k
views
How to add a number of months to a date in Polars?
I need to carry out a very simple operation in Polars, but the documentation and examples I have been finding are super convoluted. I simply have a date, and I would like to create a range running ...
1
vote
2
answers
926
views
What is the difference between relativedelta() and DateOffset()
I am having trouble understanding the differences between the relativedelta() function from the dateutil module and the DateOffset() function from Pandas. To me their syntax and outcomes are the same. ...
1
vote
1
answer
75
views
Python, Can't Transform Date Array to days
I have this csv file "rfm_data.csv":
CustomerID PurchaseDate TransactionAmount ProductInformation
8814 11-04-23 943.31 Product C
2188 11-04-23 ...
1
vote
1
answer
51
views
Label n days before and after a specific date for groups
I have a dataframe like this:
ID Date Main_Date
0 1 2015-04-02 12:00:00 False
1 1 2015-05-02 15:00:00 True
2 1 2015-02-15 00:00:00 False
3 2 2015-03-06 00:00:...
1
vote
2
answers
265
views
Taking into account weekends/holidays when using timedeltas in pandas
So heres a problem it took me a while to figure why its happening...
I have a dataframe of values with a datetime index of workdays.
Im adding a new column, 'ColB', which is always the same value as ...