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

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:

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:
Traceback (most recent call last): File "C:/Users/ashle/PycharmProjects/CSV_Handling/TradeDataManipulation/", line 9, in <module> list_stamps_date = [datetime.strptime(i,timeFormat) for i in list_stamps] File "C:/Users/ashle/PycharmProjects/CSV_Handling/TradeDataManipulation/", line 9, in <listcomp> list_stamps_date = [datetime.strptime(i,timeFormat) for i in list_stamps] File "C:\Program Files\Python36\lib\", line 565, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "C:\Program Files\Python36\lib\", 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
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

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

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to handling time series data file with Python? aupres 4 486 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  HELP- DATA FRAME INTO TIME SERIES- BASIC bntayfur 0 280 Jul-11-2020, 09:04 PM
Last Post: bntayfur
  How can I convert time-series data in rows into column srvmig 0 387 Apr-11-2020, 05:40 AM
Last Post: srvmig
  IDE for Finance TIME SERIES Data Trader2013 2 559 Jan-19-2020, 04:44 PM
Last Post: danielgoldfarb
  Apply rolling window function over time dimension of 3D data Staph 0 567 Jan-01-2020, 08:31 AM
Last Post: Staph
  Help with Data Match Theory randor 2 634 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 1,299 Apr-04-2019, 12:00 PM
Last Post: Sri
  Calculating median value from time data series mkaru 1 1,305 Aug-22-2018, 08:41 AM
Last Post: Mekire
  date format without time issac_n 6 8,971 Jan-19-2018, 10:37 AM
Last Post: issac_n
  Reduced Moving Averages for time series Data shivam_hbti 0 1,114 Oct-01-2017, 05:00 AM
Last Post: shivam_hbti

Forum Jump:

User Panel Messages

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