python-datetime Questions
2
Solved
I have a variable which is grabbing a date object from a file. My aim is to add a timezone to this object so that it automatically changes the time based on the date its it then. So I expected it t...
Miscreant asked 16/12, 2020 at 7:36
4
I have a DataFrame with incomplete dates and I only need the date/row of the last day available of each month.
I tried using TimeGrouper and take .last() of each group.
import pandas as pd
idx = [...
Relume asked 16/1, 2018 at 18:56
1
How do I convert a string to a datetime object inside of a jinja2 template?
I want to do something like the following, but strptime is not recognized.
{% set dtime=strptime(passedintime, '%H:%M:%S'...
Prestissimo asked 2/6, 2021 at 14:44
6
Solved
Is there any way to check for missing dates in a dataframe directly.
I want to check if there are a missing dates between 2013-01-19 to 2018-01-29
GWA_BTC GWA_ETH GWA_LTC GWA_XLM GWA_XRP
Date
2...
Phrase asked 27/8, 2018 at 17:34
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
5
Solved
I need to run a monthly report on the first Monday of the month and calculate this day with Python. The code I have so far will go into a module in our ETL program and will determine if the date is...
Redwood asked 4/5, 2021 at 3:19
10
Solved
What would be the best way to see if the current time lies between say 10:30 AM and 4:30 PM.
I could think of the following, not sure how correct:
from datetime import datetime
nw = datetime.now...
Andra asked 6/4, 2012 at 19:24
4
Solved
Assume I have a pydantic model
class EventEditRequest(BaseModel):
uid: UUID
name: str
start_dt: datetime
end_dt: datetime
I send request with body b'{"uid":"a38a7543-20ca-4a50-a...
Canopus asked 18/9, 2020 at 10:58
7
Solved
How can I convert a DataFrame column of strings (in dd/mm/yyyy format) to datetime dtype?
Stepha asked 16/6, 2013 at 15:14
13
Solved
Is there a nicer way than the following to return today's date in the YYYY-MM-DD format?
str(datetime.datetime.today()).split()[0]
Anemology asked 9/9, 2015 at 23:20
3
I have a date string like this and then use strptime() So its like this
my_time = datetime.datetime.strptime('07/05/15', '%m/%d/%Y')
and now I want to add 23 hours and 59 minutes to my_time
I h...
Demobilize asked 4/7, 2015 at 8:12
16
Solved
What I need to do
I have a timezone-unaware datetime object, to which I need to add a time zone in order to be able to compare it with other timezone-aware datetime objects. I do not want to conver...
Trencherman asked 15/8, 2011 at 12:55
4
Solved
Is there an elegant was to convert between relativedelta and timedelta?
The use case is getting user input ISO date. Python's isodate will return either isodate.duration.Duration or datetime.timed...
Wino asked 7/6, 2013 at 6:38
5
Solved
I have loaded a data file into a Python pandas dataframe. I has a datetime column of the format 2015-07-18 13:53:33.280.
What I need to do is create a new column that rounds this out to its neare...
Hairy asked 2/9, 2015 at 4:13
5
Solved
I am creating a module in python, in which I am receiving the date in integer format like 20120213, which signifies the 13th of Feb, 2012. Now, I want to convert this integer formatted date into a ...
Rexanna asked 17/3, 2012 at 13:26
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
6
Solved
In Python can you select a random date from a year. e.g. if the year was 2010 a date returned could be 15/06/2010
Massacre asked 21/1, 2011 at 13:21
9
Solved
I am accessing some data through an API where I need to provide the date range for my request, ex. start='20100101', end='20150415'. I thought I would speed this up by breaking up the date range in...
Lawanda asked 18/4, 2015 at 18:32
10
Solved
How can I get the first date of the next month in Python? For example, if it's now 2019-12-31, the first day of the next month is 2020-01-01. If it's now 2019-08-01, the first day of the next month...
Hourly asked 5/8, 2019 at 7:23
4
Solved
Given the string in this format "HH:MM", for example "03:55", that represents 3 hours and 55 minutes.
I want to convert it to datetime.time object for easier manipulation. What would be the easies...
Sopor asked 12/1, 2013 at 17:6
1
Solved
I have a pandas dataframe filled with time-stamped data. It is out of order; and I am trying to sort by date, hours and minutes. The pandas dataframe will organize by date, but not by hours and min...
Doublepark asked 3/11, 2022 at 4:14
4
I am trying to remove the datetime gaps in my candlestick (the gaps are the time periods when the stock market is closed, hence there are not data). Can't seem to find a good solution for using plo...
Trudietrudnak asked 7/9, 2020 at 15:15
3
I want to filter the dataframe by a certain datatime period like the following code.
df2 = df2['Dates'].between_time(pandas.to_datetime('5/13/2015 8:41'), pandas.to_datetime('5/13/2015 8:55'))[['Da...
Ninon asked 5/10, 2017 at 2:10
1 Next >
© 2022 - 2024 — McMap. All rights reserved.