Questions tagged [python-datetime]

Python's built-in datetime module provides classes for manipulating dates and times in both simple and complex ways.

Python's built-in datetime module provides classes for manipulating dates and times in both simple and complex ways.

View on Python docs - for Python 2 and Python 3.

1880 questions
0
votes
1 answer

Getting OutofBoundSDateTime on pandas to_datetime origin Parameter when origin='julian'

origin2 = pd.to_datetime([1,2,3],unit='D',origin='julian') origin2 on the above command getting the following issue : OutOfBoundsDatetime Traceback (most recent call last) in ----> 1 origin2 =…
0
votes
2 answers

How to convert Pandas column into date type when values don't respect a pattern?

I have the fallowing dataFrame: Timestamp real time 0 17FEB20:23:59:50 0.003 1 17FEB20:23:59:55 0.003 2 17FEB20:23:59:57 0.012 3 17FEB20:23:59:57 02:54.8 4 17FEB20:24:00:00 0.03 5 18FEB20:00:00:00 0 6 …
Bruno Ambrozio
  • 402
  • 3
  • 18
0
votes
2 answers

How to Have Python Make a Variable with a Data Two Years Ago from Todays Date

So I need to make a variable in python to have it send off today's date two years ago. I am having to automate a report in Salesforce using Selenium and need to have the form created by a send.keys() method from a variable. The variable I have for…
R. Barrett
  • 685
  • 11
  • 34
0
votes
1 answer

Separating Dates in Python

I am trying to do forecasting on a data using dates. The problem is i have a dataset like this LeaveStartDate TotalLeaveDays 0 2020-03-14 1.0 1 2020-03-18 2.0 2 2020-03-20 1.0 3 2020-01-13 3.0 4 2020-02-15 1.0 I want to expand…
0
votes
1 answer

Python: does not match format '%Y-%m-%d %H:%M:%S'

I have two date time dataframes which looks like: df1: 0 2020-03-16 14:00:00 1 2020-03-16 17:00:00 2 2020-03-16 20:00:00 3 2020-03-16 20:00:00 4 2020-03-16 19:00:00 5 2020-03-16 12:00:00 6 2020-03-16 18:00:00 df2: 0 2020-03-16…
user2293224
  • 2,128
  • 5
  • 28
  • 52
0
votes
2 answers

Lambda Function to return different value using parameters

I would like to use a lambda function to return values. This could be handled in a function, however would prefer the use of lambda for this exercise. In general, I want to have the lambda return either a date or 0 by passing a second…
kdb
  • 123
  • 1
  • 7
0
votes
1 answer

Pandas: Integer date not recognized with pd.to_datetime(x)

In the given dataframe, import pandas as pd import numexpr as ne op_d = {'ID': [1, 2,3],'V':['F','G','H'],'AAA':[0,1,1],'E':[20141223,20190201,20170203]…
Prish
  • 605
  • 7
  • 21
0
votes
1 answer

How can i convert a dataframe datetime columns to Quanlib Date quickly

Let's say one of the datetime column as below PORT['ISSUE_DT'] 0 2019-01-31 1 2018-10-24 2 2018-11-16 3 2018-11-16 4 2018-11-16 How can I convert it to Quanlib Date quickly? I can convert one element as below, are there any methods…
Coty Huang
  • 11
  • 2
0
votes
0 answers

Pandas: Count login days of users

I have a data frame contains one-month data. login_date user_id 0 2019-12-22 432 1 2019-12-22 432 2 2019-12-22 339 3 2019-12-23 438 4 2019-12-23 432 5 2019-12-23 431 6 2019-12-25 339 7 2019-12-25 438 8 2019-12-25 …
xcen
  • 652
  • 2
  • 6
  • 22
0
votes
1 answer

Calculate DateTimeField() via variables

I am new to python and can't wrap my head around a solution for my simple issue for days now. I have an Event model which should allow the user to book a timeslot, room and event type that will be shown in a timetable. class Event(models.Model): …
0
votes
1 answer

Gaps in data series with pandas datetimeindex

I have a pandas dataframe with the following DatetimeIndex: DatetimeIndex(['2019-06-13 15:30:00', '2019-06-13 15:31:00', '2019-06-13 15:32:00', '2019-06-13 15:33:00', .... '2020-03-06 21:56:00',…
Mark T
  • 145
  • 4
  • 12
0
votes
3 answers

Writing to csv a dictionary with datetime.datetime object as keys

I have a dictionary which contains datetime.datetime objects as keys and I would like to write them to a csv file. However, the error below is thrown: Traceback (most recent call last): File…
Nico_Robin
  • 89
  • 1
  • 9
0
votes
0 answers

Expand Date Range for search Gmail using Imapclient

So my goal is to find the last email from a contact and enter into a sheet. The current challenge is related to the Gmail part. So the current code is giving me the desired result. However, some contacts has more than 1000's of email and listing…
0
votes
2 answers

What do I have to do in Python to create an object which represents the January 1st, 2019 at 18:00 New York time (Eastern Time)?

I am trying to define a datetime object which represents January 1st, 2019 at 18:00 New York time. I try: import datetime import pytz ts = datetime.datetime(2019, 1, 1, 18, 0, 0, 0, tzinfo=pytz.timezone("US/Eastern")) print(ts) and I…
M.E.
  • 4,955
  • 4
  • 49
  • 128
0
votes
0 answers

airflow scheduler executes dag earlier than its start date

I try to execute a dag on start_date= datetime.strptime('3/2/2020 8:20:00', '%m/%d/%Y %H:%M:%S') and schedule_interval=schedule_interval='20/5 8 * * *' but dag get executed before the actual start_date. from datetime import datetime from airflow…