I'm trying to find the average value of two columns 'GBP' and 'USD' based on the specific year of 2020 from the 'Date' column inside a Pandas DataFrame.
The original question: "What was the average value of the £ in 2020 against the $"
What I've done:
import pandas as pd
df = pd.read_csv ('C:/Users/user/AppData/Local/Programs/Python/Python39/Scripts/usd_vs_gbp_euro_2011_2021.csv')
print(df.groupby('Date').GBP.mean())
print(df.groupby('Date').USD.mean())
However, this code prints the mean for every year, not just the year 2020. Can anyone point out where I'm getting wrong or suggest some solutions?
Note: I'm new to Python and using DataFrames.