I'm trying to resample and plot the average temperature of a city from a dataframe by year using Pandas. I'm successfully creating a copy of the data however, I keep running into this issue.
Note: The column name of the date is dt.
CodePudding user response:
You are telling pandas to look for a column called 'Y' but the KeyError is telling you that this pandas data frame doesn't have a column called 'Y'
Here's a more detailed explanation of the error.
CodePudding user response:
You only save the AverageTemperature column. Try keeping all columns, or at least include the Y column too:
df2 = df[(df['City'] == 'Aden') & (df['Country'] == 'Yemen')].copy()