Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------------------
- KeyError Traceback (most recent call last)
- <ipython-input-64-9dfdda7a59fb> in <module>
- 1 # Check your answer
- ----> 2 q_3.check()
- /opt/conda/lib/python3.6/site-packages/learntools/core/problem_view.py in wrapped(self, *args, **kwargs)
- 22 def wrapped(self, *args, **kwargs):
- 23 self.interactions[method.__name__] += 1
- ---> 24 return method(self, *args, **kwargs)
- 25 return wrapped
- 26
- /opt/conda/lib/python3.6/site-packages/learntools/core/problem_view.py in wrapped(*args, **kwargs)
- 13 @functools.wraps(fn)
- 14 def wrapped(*args, **kwargs):
- ---> 15 res = fn(*args, **kwargs)
- 16 display(res)
- 17 # Don't propagate the return to avoid double printing.
- /opt/conda/lib/python3.6/site-packages/learntools/core/problem_view.py in check(self)
- 91 args = ()
- 92 self.problem.check_whether_attempted(*args)
- ---> 93 self.problem.check(*args)
- 94 except NotAttempted as e:
- 95 self._track_check(tracking.OutcomeType.UNATTEMPTED)
- /opt/conda/lib/python3.6/site-packages/learntools/sql/ex5.py in check(self, results)
- 100 year_to_check = list(rides_per_year_answer["year"])[0]
- 101 correct_number = int(rides_per_year_answer.loc[rides_per_year_answer["year"]==year_to_check]["num_trips"][0])
- --> 102 submitted_number = int(results.loc[results["year"]==year_to_check]["num_trips"][0])
- 103 assert (correct_number == submitted_number), ("The results don't look right. Try again.")
- 104
- /opt/conda/lib/python3.6/site-packages/pandas/core/series.py in __getitem__(self, key)
- 765 key = com._apply_if_callable(key, self)
- 766 try:
- --> 767 result = self.index.get_value(self, key)
- 768
- 769 if not is_scalar(result):
- /opt/conda/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_value(self, series, key)
- 3116 try:
- 3117 return self._engine.get_value(s, k,
- -> 3118 tz=getattr(series.dtype, 'tz', None))
- 3119 except KeyError as e1:
- 3120 if len(self) > 0 and self.inferred_type in ['integer', 'boolean']:
- pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()
- pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()
- pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
- pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
- pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
- KeyError: 0
Advertisement
Add Comment
Please, Sign In to add comment