I have a dictionary in which I've put several dataframes (all identical at this point). I'm trying to add data into the same column of each of those dataframes (fiscal year) corresponding to the key by which each dataframe can be called. The keys that I've assigned are the fiscal years. When I try to use dict.items(), however, it assigns each of the dataframes the same value (the last fiscal year). The goal is to forecast the revenue by fiscal year where I will break revenue into a new column according to how much will be garnered in each year. I've simplified my code to the below:
import pandas as pd
columns = ['ID','Revenue','Fiscal Year']
ID = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Revenue = [1000, 1200, 1300, 100 ,500, 0, 800, 950, 4321, 800]
FY = []
d = {'ID': ID, 'Revenue': Revenue}
df = pd.DataFrame(d)
df['Fiscal Year'] = ''
dataframe_dict = {}
def df_dict_func(start, end, dataframe):
date_range = range(start, end + 1)
for n in date_range:
dataframe_dict[n] = dataframe
for key, value in dataframe_dict.items():
value['Fiscal Year'] = key
df_dict_func(2018, 2025, df)
print(dataframe_dict[2019])