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'
#2
Please here is attached the error:
1 #Converting time to timestamp ( a datetime object)
----> 2 data['Timestamp']=pd.to_datetime(data['Time'])
3
4 # Ensuring there are no temporal gaps

---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/opt/anaconda3/envs/python3b/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2645 try:
-> 2646 return self._engine.get_loc(key)
2647 except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index_class_helper.pxi in pandas._libs.index.Int64Engine._check_type()

KeyError: 'Time'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
<ipython-input-9-9b4c885821b2> in <module>
1 #Converting time to timestamp ( a datetime object)
----> 2 data['Timestamp']=pd.to_datetime(data['Time'])
3
4 # Ensuring there are no temporal gaps
5 plt.figure(num=1, figsize=(10,5))

~/opt/anaconda3/envs/python3b/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
2798 if self.columns.nlevels > 1:
2799 return self._getitem_multilevel(key)
-> 2800 indexer = self.columns.get_loc(key)
2801 if is_integer(indexer):
2802 indexer = [indexer]

~/opt/anaconda3/envs/python3b/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2646 return self._engine.get_loc(key)
2647 except KeyError:
-> 2648 return self._engine.get_loc(self._maybe_cast_indexer(key))
2649 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
2650 if indexer.ndim > 1 or indexer.size > 1:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index_class_helper.pxi in pandas._libs.index.Int64Engine._check_type()

KeyError: 'Time'
Reply


Messages In This Thread
RE: Read CSV error: python KeyError: 'Time' - by charlicruz - Jun-27-2020, 09:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formatting a date time string read from a csv file DosAtPython 5 1,421 Jun-19-2023, 02:12 PM
Last Post: DosAtPython
  Plotting by Time, error mansoorahs 1 771 May-16-2023, 09:46 AM
Last Post: Larz60+
  Read nested data from JSON - Getting an error marlonbown 5 1,446 Nov-23-2022, 03:51 PM
Last Post: snippsat
  How to change UTC time to local time in Python DataFrame? SamKnight 2 1,669 Jul-28-2022, 08:23 AM
Last Post: Pedroski55
  How to read rainfall time series and insert missing data points MadsM 4 2,248 Jan-06-2022, 10:39 AM
Last Post: amdi40
  Error When Trying To Read CSV File kaega2 3 5,635 Dec-03-2021, 09:10 PM
Last Post: kaega2
  Is there a way to read the time between clicks? penahuse 1 2,541 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,558 Dec-08-2020, 10:11 PM
Last Post: greenpine
  Time Limit Exceeded error loves 5 3,199 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,800 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