Python Forum
Read CSV error: python KeyError: 'Time'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read CSV error: python KeyError: 'Time'
#1
have the following csv structure file. Time 1 2 3 01/01/2010 00:00 274,16 576,44 1523,9

I tried to convert time to timestamp but I cannot plot the data as I get the following error:

Error:
File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'Time'
data=pd.read_csv('test.csv', delimiter='delimiter', header='infer')
data.head()
data['Timestamp']=pd.to_datetime(data['Time'])
plt.figure(num=1, figsize=(10,5))
data.Timestamp.plot() #Plotting the newly added timestamp column
plt.xlabel('Reading Count')
plt.ylabel('Date')
plt.show()
I am wondering if anybody could help me to plot some data from the excel source provided in the following Github link: https://github.com/charlicruz/Energy-Demand
Reply


Messages In This Thread
Read CSV error: python KeyError: 'Time' - by charlicruz - Jun-26-2020, 01:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formatting a date time string read from a csv file DosAtPython 5 1,391 Jun-19-2023, 02:12 PM
Last Post: DosAtPython
  Plotting by Time, error mansoorahs 1 763 May-16-2023, 09:46 AM
Last Post: Larz60+
  Read nested data from JSON - Getting an error marlonbown 5 1,435 Nov-23-2022, 03:51 PM
Last Post: snippsat
  How to change UTC time to local time in Python DataFrame? SamKnight 2 1,655 Jul-28-2022, 08:23 AM
Last Post: Pedroski55
  How to read rainfall time series and insert missing data points MadsM 4 2,230 Jan-06-2022, 10:39 AM
Last Post: amdi40
  Error When Trying To Read CSV File kaega2 3 5,613 Dec-03-2021, 09:10 PM
Last Post: kaega2
  Is there a way to read the time between clicks? penahuse 1 2,532 Jan-30-2021, 10:46 PM
Last Post: Larz60+
  how to change the range of read CSV file every time python file runs greenpine 6 4,542 Dec-08-2020, 10:11 PM
Last Post: greenpine
  Time Limit Exceeded error loves 5 3,188 Dec-03-2020, 07:15 AM
Last Post: Sofia_Grace
  How to read CSV file one row at the time in a range and some delay in between greenpine 2 4,795 Nov-20-2020, 02:26 PM
Last Post: greenpine

Forum Jump:

User Panel Messages

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