markwk / qs_ledger

Quantified Self Personal Data Aggregator and Data Analysis
MIT License
978 stars 197 forks source link

Error on running Todoist analysis #4

Open mbbroberg opened 5 years ago

mbbroberg commented 5 years ago

I'm working from the Jupyter Notebook launched by Anaconda Navigator and I'm running each section one-by-one. I pulled the data using your script at https://github.com/markwk/todoist_export. After importing and running the other earlier tasks, I then grab the data from that location.

tasks = pd.read_csv("/Users/mbbroberg/Develop/todoist_export/data/todost-tasks-completed.csv")
len(tasks)

Once I reach year_data = tasks['year'].value_counts().sort_index(), I receive the error below. When I look at the tasks object, I don't see a column for year (see screenshot). Is it possible I'm looking at the wrong data or am I missing something?

Screen Shot 2019-04-15 at 4 23 32 PM
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2656             try:
-> 2657                 return self._engine.get_loc(key)
   2658             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/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'year'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-24-a30ed33e8ded> in <module>
----> 1 year_data = tasks['year'].value_counts().sort_index()

/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key)
   2925             if self.columns.nlevels > 1:
   2926                 return self._getitem_multilevel(key)
-> 2927             indexer = self.columns.get_loc(key)
   2928             if is_integer(indexer):
   2929                 indexer = [indexer]

/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2657                 return self._engine.get_loc(key)
   2658             except KeyError:
-> 2659                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2660         indexer = self.get_indexer([key], method=method, tolerance=tolerance)
   2661         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/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'year'
mbbroberg commented 5 years ago

A few more notes here:

markwk commented 4 years ago

@mbbroberg looks like todoist api needs updating. I re-ran it today and it initially didn't work and said endpoint didn't exist but then went back an hour later and it worked fine. Seems like this will need a re-write in places there. Did you manage to make any progress?