Skip to main content

All Questions

Tagged with
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(...
Tony's user avatar
  • 1
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 ...
Qaribbean's user avatar
  • 190
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 ...
datadatadata's user avatar
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 ...
Shichimi's user avatar
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 ...
Edge's user avatar
  • 2,540
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/...
Zhao's user avatar
  • 41
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 ...
user_5's user avatar
  • 576
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 ...
Jresearcher's user avatar
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 ...
Malina's user avatar
  • 1
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
S. Bharanidharan's user avatar
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 ...
jmarusiak's user avatar
  • 145
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, ...
TiTo's user avatar
  • 865
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 ...
GusRo's user avatar
  • 7
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 ...
houayang's user avatar
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 ...
SeaDude's user avatar
  • 4,425

15 30 50 per page