Hello folks! I need help with python coding. I have a dictionary who keys are years, and values are dataframes. See image. Now the goal is to iterate through each dataframe and assign to each row under COL-ADD which is ‘Period’, Period 01, Period 02, …, Period n for each year.
These are the variables
dictionary = year_list_dict
dictionary keys are exact values stored in >> data_year_list
<> the elements in the data_year_list are string values but can easily be converted to integers — so are the dictionary keys (I actually have a line that converts between int() and str())
column to add = ‘Period’
<> original dataframe was a dataset of multiple years which I used a .groupby() on to group each year as a dataframe assign to their respective years into a dictionary
Thanks for the much needed help!!!
The second picture is the line set I’m running.
The third picture is the result…obviously wrong.