timedelta Questions
5
Solved
I have a column in a pandas dataframe that is created after subtracting two times. I now have a timedelta object like this -1 days +02:45:00. I just need to remove the -1 days and want it to be 02:...
8
Solved
I do a calculation of average time, and I would like to display the resulted average without microseconds.
avg = sum(timedeltas, datetime.timedelta(0)) / len(timedeltas)
5
Solved
Specifically, given the timezone of my server (system time perspective) and a timezone input, how do I calculate the system time as if it were in that new timezone (regardless of daylight savings, ...
6
I would like to write a script where I give Python a number of days (let's call it d) and it gives me the date we were d days ago.
I am struggling with the module datetime:
import datetime
tod = ...
Mellissamellitz asked 1/2, 2015 at 22:43
3
Solved
I have a Pandas dataframe with 2 columns representing a start-timestamp and an end-timestamp:
start end
2016-06-13 2016-07-20
The datatype of these columns is datetime64[ns].
I now want to crea...
Emmittemmons asked 19/8, 2018 at 13:16
5
Solved
Given a datetime.timedelta, how to convert it into an ISO 8601 duration string?
For example, given datetime.timedelta(0, 18, 179651), how do I get 'PT18.179651S'?
For the reverse, see Is there an ...
Lassie asked 27/11, 2014 at 10:20
8
How can I convert an ISO 8601 duration string to datetime.timedelta?
I tried just instantiating timedelta with the duration string and a format string, but I get an exception:
>>> from dat...
Pelota asked 2/5, 2016 at 6:25
2
I have a table of items with the following columns:
start_time column (timestamp without time zone)
expiration_time_seconds column (integer)
For example, some values are:
SELECT start_time, ex...
6
Solved
What is the proper way to convert a timedelta object into a datetime object?
I immediately think of something like datetime(0)+deltaObj, but that's not very nice... Isn't there a toDateTime() func...
6
Solved
I have a time difference
import time
import datetime
time1 = datetime.datetime.fromtimestamp(time.mktime(time.gmtime()))
...
time2 = datetime.datetime.fromtimestamp(time.mktime(time.gmtime()))
dif...
35
Solved
3
Solved
I have the following time:
time = datetime.timedelta(days=1, hours=4, minutes=5, seconds=33, milliseconds=623)
Is it possible, to convert the time in milliseconds?
Like this:
101133623.0
6
I am attempting to use argparse to convert an argument into a timedelta object. My program reads in strings supplied by the user and converts them to various datetime objects for later usage. I can...
5
Solved
What is the difference between datetime.timedelta (from Python's standard library) and dateutil.relativedelta.relativedelta when working only with days?
As far as I understand, timedelta only supp...
18
Solved
I have a date "10/10/11(m-d-y)" and I want to add 5 days to it using a Python script. Please consider a general solution that works on the month ends also.
I am using following code:
impo...
6
Solved
I was trying to round off time to the nearest hour in python in a dataframe.
Suppose if a timestamp is 2017-11-18 0:16 it should come as 2017-11-18 0:00
and 2017-11-18 1:56 should round off as 201...
12
Solved
I'm writing a function that needs to parse string to a timedelta. The user must enter something like "32m" or "2h32m", or even "4:13" or "5hr34m56s"... Is th...
46
Solved
I'm using Java's java.util.Date class in Scala and want to compare a Date object and the current time. I know I can calculate the delta by using getTime():
(new java.util.Date()).getTime() - oldDa...
Interface asked 12/10, 2009 at 15:35
1
Solved
The date series is something like this:
df.d_num_active.head()
# result
0 191 days
1 49 days
2 273 days
3 287 days
4 634 days
Name: d_num_active, dtype: timedelta64[ns]
The problem:
>>> ...
Ingressive asked 27/4, 2023 at 11:12
7
Solved
From:
http://docs.python.org/py3k/library/datetime.html#timedelta-objects
A timedelta object represents a duration, the difference between two
dates or times.
So why i get error with this:
...
8
Solved
I have a Python datetime.datetime object. What is the best way to subtract one day?
4
Solved
I have two columns, fromdate and todate, in a dataframe.
import pandas as pd
data = {'todate': [pd.Timestamp('2014-01-24 13:03:12.050000'), pd.Timestamp('2014-01-27 11:57:18.240000'), pd.Timestamp...
Symposium asked 7/4, 2014 at 21:49
9
Solved
I have a pandas dataframe looking like this:
Name start end
A 2000-01-10 1970-04-29
I want to add a new column providing the difference between the start and end column in years, months, days.
...
7
Solved
In Python, how do I get a datetime object for '3 years ago today'?
UPDATE: FWIW, I don't care hugely about accuracy... i.e. it's Feb 29th today, I don't care whether I'm given Feb 28th or March 1s...
14
Solved
I've got a timedelta. I want the days, hours and minutes from that - either as a tuple or a dictionary... I'm not fussed.
I must have done this a dozen times in a dozen languages over the years bu...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.