I'm trying to make a lineplot using seaborn, but it Could not interpret value.
Year Mean
0 1960 3.454839
1 1961 3.234961
2 1962 3.438915
3 1963 3.240369
4 1964 3.209732
... ... ...
56 2016 1.935616
57 2017 1.879151
58 2018 1.824546
59 2019 1.844573
60 2020 1.99145
This is the df and that's what i tell to sns:
sns.lineplot(data=df2, x="Year", y="Mean")
The same happens in scatterplot. This is what I get.
ValueError: Could not interpret value `Year` for parameter `x`
CodePudding user response:
I put this sample data into my editor vscode
and it works. So as many have suggested, it must be with the construct of the dataframe
and probably the Year
header.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
d = {'Year':[1960, 1965, 1970], 'Mean':[3.1, 3.2, 3.3]}
df = pd.DataFrame(d)
print(df)
sns.lineplot(data=df, x="Year", y="Mean")
plt.show()
CodePudding user response:
So it turns out there was something wrong with the names of the columns, i used df2.columns = ["Year", "Mean"] and everything worked. –