Deal all and team,
In first ungraded lab of Module 2, every building block is running properly, but I have an error message when running the whole workflow (last code cell).
It looks like there is an error with key “quarter” although this key does actually exist in coffee_sales.csv (and again, this works perfectly when computing the building blocs one after another).
Any idea what I should try ? Many thanks !
This is the error I get:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3641, in Index.get_loc(self, key)
3640 try:
-> 3641 return self._engine.get_loc(casted_key)
3642 except KeyError as err:
File pandas/_libs/index.pyx:168, in pandas._libs.index.IndexEngine.get_loc()
File pandas/_libs/index.pyx:197, in pandas._libs.index.IndexEngine.get_loc()
File pandas/_libs/hashtable_class_helper.pxi:7668, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas/_libs/hashtable_class_helper.pxi:7676, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'quarter'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Cell In[10], line 9
6 image_basename="drink_sales"
8 # Run the complete agentic workflow
----> 9 _ = run_workflow(
10 dataset_path="coffee_sales.csv",
11 user_instructions=user_instructions,
12 generation_model=generation_model,
13 reflection_model=reflection_model,
14 image_basename=image_basename
15 )
Cell In[9], line 41, in run_workflow(dataset_path, user_instructions, generation_model, reflection_model, image_basename)
39 initial_code = match.group(1).strip()
40 exec_globals = {"df": df}
---> 41 exec(initial_code, exec_globals)
42 utils.print_html(out_v1, is_image=True, title="Generated Chart (V1)")
44 # 3) Reflect on V1 (image + original code) to get feedback and refined code (V2)
File <string>:8
File /usr/local/lib/python3.11/site-packages/pandas/core/frame.py:4378, in DataFrame.__getitem__(self, key)
4376 if self.columns.nlevels > 1:
4377 return self._getitem_multilevel(key)
-> 4378 indexer = self.columns.get_loc(key)
4379 if is_integer(indexer):
4380 indexer = [indexer]
File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3648, in Index.get_loc(self, key)
3643 if isinstance(casted_key, slice) or (
3644 isinstance(casted_key, abc.Iterable)
3645 and any(isinstance(x, slice) for x in casted_key)
3646 ):
3647 raise InvalidIndexError(key) from err
-> 3648 raise KeyError(key) from err
3649 except TypeError:
3650 # If we have a listlike key, _check_indexing_error will raise
3651 # InvalidIndexError. Otherwise we fall through and re-raise
3652 # the TypeError.
3653 self._check_indexing_error(key)
KeyError: 'quarter'


