Python Forum
Time Data does not match format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Time Data does not match format
#1
Hi,

I have the following code:

import pandas as pdm
from datetime import datetime,timedelta
timeFormat = '%d/%m?%y %H:%M:%S'


dataFrame = pdm.read_csv('C:\\', sep=',', index_col=None)
list_stamps = dataFrame['Timestamp'].tolist()
list_stamps_date = [datetime.strptime(i,timeFormat) for i in list_stamps]
and unfortunately, when i'm trying to read the following string "22/10/18 08:00:00" i get the following error:

Error:
ValueError: time data '22/10/18 08:00:00' does not match format '%d/%m?%y %H:%M:%S'
for clarity the full error is:
Error:
Traceback (most recent call last): File "C:/Users/ashle/PycharmProjects/CSV_Handling/TradeDataManipulation/Momentum.py", line 9, in <module> list_stamps_date = [datetime.strptime(i,timeFormat) for i in list_stamps] File "C:/Users/ashle/PycharmProjects/CSV_Handling/TradeDataManipulation/Momentum.py", line 9, in <listcomp> list_stamps_date = [datetime.strptime(i,timeFormat) for i in list_stamps] File "C:\Program Files\Python36\lib\_strptime.py", line 565, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "C:\Program Files\Python36\lib\_strptime.py", line 362, in _strptime (data_string, format)) ValueError: time data '22/10/18 08:00:00' does not match format '%d/%m?%y %H:%M:%S' Process finished with exit code 1
I'm early stages of teaching myself python so I'm sure someone will groan at my stupidity, but I can't seem to spot the obvious problem!!!.

all help much appreciated
Reply
#2
you have ? instead of / in the format string
%d/%m?%y %H:%M:%S
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Haha - I'm so sorry you actually had to look at that. Thanks so much.....
really appreciate it
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help: Conversion of Electricity Data into Time Series Data SmallGuy 3 1,155 Oct-04-2023, 03:31 PM
Last Post: deanhystad
  how to handling time series data file with Python? aupres 4 2,924 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  HELP- DATA FRAME INTO TIME SERIES- BASIC bntayfur 0 1,732 Jul-11-2020, 09:04 PM
Last Post: bntayfur
  How can I convert time-series data in rows into column srvmig 0 2,032 Apr-11-2020, 05:40 AM
Last Post: srvmig
  IDE for Finance TIME SERIES Data Trader2013 2 64,772 Jan-19-2020, 04:44 PM
Last Post: danielgoldfarb
  Apply rolling window function over time dimension of 3D data Staph 0 2,160 Jan-01-2020, 08:31 AM
Last Post: Staph
  Help with Data Match Theory randor 2 2,000 Dec-25-2019, 05:57 PM
Last Post: randor
  [pandas]How to liner fit time series data and get linear fit equation and r square Sri 5 3,755 Apr-04-2019, 12:00 PM
Last Post: Sri
  Calculating median value from time data series mkaru 1 5,034 Aug-22-2018, 08:41 AM
Last Post: Mekire
  date format without time issac_n 6 14,069 Jan-19-2018, 10:37 AM
Last Post: issac_n

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020