user7310181
user7310181

Reputation:

Error occurring while retrieving a csv data file in python

Given this code:

import pandas as pd
import numpy as np
import matplotlib.pylab as plt
from matplotlib.pylab import rcParams
dateparse = lambda dates : pd.datetime(date, '%Y-%m')
data = pd.read_csv('F2016_11_18_14-2016_11_18_21_datafile.csv', parse_dates='Date', index_col = 'Date', date_parser=dateparse)
print (data.head())

I get a TypeError:

TypeError: Only booleans, lists, and dictionaries are accepted for the 'parse_dates' parameter

I don't understand why this is happening.

Here's a sample of my data:

Date        Time_GMT    Time_IST    Current
11/18/2016  9:00:00     14:30:00    20.9
11/18/2016  9:00:01     14:30:01    23.37
11/18/2016  9:00:02     14:30:02    24.11
11/18/2016  9:00:03     14:30:03    26.51
11/18/2016  9:00:04     14:30:04    28.9
11/18/2016  9:00:05     14:30:05    24.21
11/18/2016  9:00:06     14:30:06    23.21

Upvotes: 2

Views: 4999

Answers (1)

MaxU - stand with Ukraine
MaxU - stand with Ukraine

Reputation: 210912

As the error says, parse_dates accepts only booleans, lists or dictionaries, so try this: parse_dates=['Date'] instead of parse_dates='Date'

Upvotes: 9

Related Questions