atharvapathak/Sales_Forecasting_Project

All groupby statements in generate_lag_features cause SpecificationError("nested renamer is not supported")

Opened this issue · 0 comments

Hi,
I am attempting to use your project to predict store sales for a small chain of bakeries.
I am using the source code extracted from the jupyter notebooks directly.
In generate_lag_features in several places you use the pandas groupby function. For example:

gb = sales.groupby(index_cols,as_index=False).agg({'item_cnt_day':{'target':'sum'}})

I am using pandas 2.2.1. The above statement generates the traceback reported below.

Based on seaches I ran the error SpecificationError("nested renamer is not supported") is caused by this construct

agg({'item_cnt_day':{'target':'sum'}})

I read the comment in the noteboook regarding the above line. Frankly, I am not sufficiently familiar with your code to try and change the above construct so as to resolve the error.

Could you help me?

Thanks

TRACEBACK LOG

Traceback (most recent call last):
  File "/home/adonnini1/Development/ContextQSourceCode/NeuralNetworks/RetailSalesForecasting/Sales_Forecasting_Project/downloadedNotebooks/generate_lag_features.py", line 68, in <module>
    gb = sales.groupby(index_cols,as_index=False).agg({'item_cnt_day':{'target':'sum'}})
  File "/usr/local/lib/python3.10/site-packages/pandas/core/groupby/generic.py", line 1432, in aggregate
    result = op.agg()
  File "/usr/local/lib/python3.10/site-packages/pandas/core/apply.py", line 190, in agg
    return self.agg_dict_like()
  File "/usr/local/lib/python3.10/site-packages/pandas/core/apply.py", line 423, in agg_dict_like
    return self.agg_or_apply_dict_like(op_name="agg")
  File "/usr/local/lib/python3.10/site-packages/pandas/core/apply.py", line 1608, in agg_or_apply_dict_like
    result_index, result_data = self.compute_dict_like(
  File "/usr/local/lib/python3.10/site-packages/pandas/core/apply.py", line 462, in compute_dict_like
    func = self.normalize_dictlike_arg(op_name, selected_obj, func)
  File "/usr/local/lib/python3.10/site-packages/pandas/core/apply.py", line 655, in normalize_dictlike_arg
    raise SpecificationError("nested renamer is not supported")
pandas.errors.SpecificationError: nested renamer is not supported