-2
I’m using a sequence of codes to apply in a forecasting
:
'''
dataparse = lambda dates: pd.datetime.strptime(dates, '%d/%m/%Y')
df = pd.read_csv('BBSE3.csv', encoding ='utf8', sep=';', parse_dates =
['Data'], index_col = 'Data', date_parser = dateparse)
'''
But is returning the following error:
~\Anaconda3 lib_strptime.py in _strptime(data_string, format) 360 if not found: 361 raise Valueerror("time data %r does not match format %r" % --> 362 (data_string, format)) 363 if Len(data_string) != found.end(): 364 raise Valueerror("unconverted data remains: %s" %
Valueerror: time data '02/01/2018' does not match format 'dd/mm/yyyy'
df.head(5)
Data Valor
0 2018-02-01 28.7
1 2018-03-01 28.72
2 2018-04-01 28.78
3 2018-05-01 28.97
4 2018-08-01 29.14
Invert the date format reference to "%Y/%m/%d"
but the error persists:
ValueError: time data '02/01/2018' does not match format '%Y/%m/%d'
There is some other problem there, in parts of your code or data that are not in the question. If we try to apply the example you have there, parse works, only with atda.. Try adding some lines of the CSV file in your question.
– jsbueno
Transform the spine Date for the format
datetime
after uploading the file would be a valid answer for you? Or the question is unique to the parse within the commandread_csv
?– Terry
@Terry, it could be during the loading or after, I just thought to do during the load to expedite the process in already being with the data in the appropriate format for the statistical treatments that I will perform. Is there any best practice in this regard?
– Claudio Fagundes Pereira