All Questions
34 questions
0
votes
0
answers
77
views
Why Python relativedelta perform like this?
I use the following Python to calculate the difference between two dates.
from dateutil.relativedelta import relativedelta
from datetime import datetime
date1 = datetime(2023,3,30)
date2 = datetime(...
0
votes
1
answer
58
views
How can I calculate a date differential in Python across multiple rows and columns?
I'm trying to calculate the differential between the first Sent date/time in an ID and the last Received date/time in an ID, grouping them by Source and Destination. Sample (named test_subset) looks ...
1
vote
1
answer
347
views
Compute time differences between shifts with pandas
Let's say we have the following pandas dataframe, working on python:
worker
shift_start
shift_end
function
Alice
2022-01-15 11:30:00
2022-01-15 15:30:00
A
Alice
2022-01-15 17:30:00
2022-01-15 18:29:59
...
1
vote
2
answers
145
views
How to count date difference in python
I have a data frame named table which looks like below
Date ID
0 2015-12-30 2658789.0
1 2017-04-12 2658789.0
2 2014-06-23 2658789.0
3 2015-12-30 2658789.0
4 2016-01-06 ...
0
votes
2
answers
72
views
Pandas dataframe drop multiple rows based on datetime difference
I store datetimes in a pandas dataframe which look like dd/mm/yyyy hh:mm:ss
I want to drop all rows where values in column x (datetime) are within 24 hours of one another.
On a 1 by 1 basis, I was ...
1
vote
1
answer
567
views
How to get the next date in python?
I have two series in my dataframe to calculate next payment date, one is start date, the other is payment frequency.
How to get the next payment date in python?
For example, the start date is 2021/12/...
1
vote
2
answers
1k
views
Pyspark use partition or groupby with agg and datediff
I'm new to Pyspark.
I would like to find the products not seen after 10 days from the first day they entered the store. And create a column in dataframe and set it to 1 for these products and 0 for ...
0
votes
1
answer
953
views
Date Difference between timestamp excluding weekends and range time (out of business hours) Pyspark
I have, for each ID, a "start_date" timestamp column and I would like to calculate the exact difference with an "end_date" date but with a particularity: I would like count all ...
0
votes
1
answer
237
views
How to calculate percentage difference between two data frames with Pandas and return column and row names?
I use pandas
For example, i have 2 df with same names of columns and rows
df1
name a b
0 row1 3 2
1 row2 7 2
2 row3 1 6
df2
name a b
0 row1 4 2
1 row2 ...
0
votes
1
answer
70
views
How to drop rows and columns with nulls in one column pyspark
How to drop rows with nulls in one column pyspark
1
vote
1
answer
122
views
Rolling datediff over rows, multiple keys
I have a dataframe that looks like this:
Part
Date
1
9/1/2021
1
9/8/2021
1
9/15/2021
2
9/1/2020
2
9/12/2020
2
9/14/2020
The dataframe is already sorted by part, then by date.
I need to calculate the ...
0
votes
0
answers
371
views
Clever way to get days between two dates with daylight saving in PySpark
I need to calculate the difference in days between two timestamps of a PySpark DataFrame. Usually the difference between the timestamps should be full days but as the dates include daylight saving, ...
0
votes
1
answer
39
views
Python_Converting datetime difference into days difference
I want to calculate the time difference between rows and express it in days.
for example datetime1(MM/DD/YY hh:mm:ss) - datetime2(MM/DD/YY hh:mm:ss) = 0.5 (days)
Below an example of the data and ...
2
votes
1
answer
186
views
How do I get difference between two dates but also have a way to sum up hours by day?
I'm a little new to Python and I'm not sure where to start.
I have a python dataframe that contains shift information like the below:
EmployeeID ShiftType BeginDate EndDate
10 ...
1
vote
3
answers
1k
views
How to correctly generate list of UTC timestamps, by hour, between two datetimes Python?
I'm new to Python. After a couple days researching and trying things out, I've landed on a decent solution for creating a list of timestamps, for each hour, between two dates.
Example:
import datetime
...