Amigos, boa tarde!
Estou iniciando na programação Python. E estou encontrando este erro:
not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique())
KeyError: "None of [Index(['1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998',\n
'1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007',\n
'2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016',\n
'2017', '2018', '2019', '2020', '2021'],\n
dtype='object')] are in the [columns]"
Meu dataframe df_tot
Ao tentar executar este código para gerar um gráfico de regressão
#YEARS which we will use for plotting later
years = list(map(str, range(1990, 2022)))
#Using the sum() method to get the total fuel per year
df_tot = pd.DataFrame(df_comb[years].sum(axis=0))
df_tot.head()
#change the years to type float (useful for regression later on)
df_tot.index = map(float, df_tot.index)
#reset the index to put in back in as a column in the df_tot dataframe
df_tot.reset_index(inplace=True)
#rename columns
df_tot.columns = ['year', 'TOTAL']
#view the final dataframe
df_tot.head()
Obrigado!