Emmanuel Gonzales II Emmanuel Gonzales II - 2 months ago 9x
Python Question

Can't call the time data in python

I have this csv data below:

2015-01-02,02:29:45 PM,Red
2015-01-02,05:16:15 PM,Red
2015-01-02,05:48:46 PM,Blue
2015-01-02,03:18:34 PM,Blue
2015-01-02,05:22:55 PM,Red
2015-01-02,03:25:45 PM,Blue
2015-01-02,04:23:16 PM,Red

I am trying to plot this data into a graph using matplotlib
where x-axis = Date, y-axis = time, values = either red or blue colored points
However, I am getting this error when trying to call the time column:

time = df('Time')
print (time.head())
**DataFrame' object is not callable**

But if I call the date column, it works fine:

date = df['Date']
print (date.head())

0 2015-01-02
1 2015-01-02
2 2015-01-02
3 2015-01-02
4 2015-01-02
Name: Date, dtype: datetime64[ns]

hd1 hd1
time = df['Time']

Use the [] instead of () when accessing columns in a pandas dataframe.