I am trying to add a horizontal line in a scatter plot based on a column of the dataframe - i got the following error: ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
x_line = datLong.groupby('ctr1').agg({'maxx': ['mean']})
for country in datLong.ctr1.unique():
temp_df = plt.figure(country)
temp_df = datLong[datLong.ctr1 == country]
ax1 = temp_df.plot(kind='scatter', x='x', y='Price', color='#d95f0e', label = 'xx', linewidth =3, alpha = 0.7, figsize=(7,4))
plt.title(country)
plt.axvline(x=x_line) ### this is the line that is causing this error
plt.show()
print (ax1)
The problem seems to be related to the dataframe. But I can figure out what it is? can anybody help me