Module 2, ungraded lab

3.2. Step 2 — Execute Code and Create Chart
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3805, in Index.get_loc(self, key)
3804 try:
-> 3805 return self._engine.get_loc(casted_key)
3806 except KeyError as err:

File index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()

File index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:7089, 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[11], line 7
5 utils.print_html(initial_code, title="Extracted Code to Execute")
6 exec_globals = {"df": df}
----> 7 exec(initial_code, exec_globals)
9 # If code run successfully, the file chart_v1.png should have been generated
10 utils.print_html(
11 content="chart_v1.png",
12 title="Generated Chart (V1)",
13 is_image=True
14 )

File <string>:8

File /usr/local/lib/python3.11/site-packages/pandas/core/frame.py:4102, in DataFrame.__getitem__(self, key)
4100 if self.columns.nlevels > 1:
4101 return self._getitem_multilevel(key)
-> 4102 indexer = self.columns.get_loc(key)
4103 if is_integer(indexer):
4104 indexer = [indexer]

File /usr/local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
3807 if isinstance(casted_key, slice) or (
3808 isinstance(casted_key, abc.Iterable)
3809 and any(isinstance(x, slice) for x in casted_key)
3810 ):
3811 raise InvalidIndexError(key)
-> 3812 raise KeyError(key) from err
3813 except TypeError:
3814 # If we have a listlike key, _check_indexing_error will raise
3815 # InvalidIndexError. Otherwise we fall through and re-raise
3816 # the TypeError.
3817 self._check_indexing_error(key)

KeyError: 'quarter'
this error occur when I run the cell:

match = re.search(r"<execute_python>([\s\S]*?)</execute_python>", code_v1)
if match:
initial_code = match.group(1).strip()
utils.print_html(initial_code, title="Extracted Code to Execute")
exec_globals = {"df": df}
exec(initial_code, exec_globals)

utils.print_html(
content="chart_v1.png",
title="Generated Chart (V1)",
is_image=True
)

hi @hasanSHa

this issue is already reported to staff, kindly wait for their response. there is deprecation issue with model version.

appreciate your reporting this issue and patience, while staff working to resolve.

regards

dr. deepti

Notebooks in the Agentic Course have been updated to newer gpt model, from o4-mini → gpt-5-mini

Currently, all notebooks are up and running :raising_hands:

Happy Learning!

-- Lesly, DLAI