I was loading dataframe in df and need to plot stacked plot
This is the code I wrote to load dataframe iris in df and to plot stacked area plot
import matplotlib.pyplot as plt import seaborn as sns def read_dataset(): df = sns.load_dataset('iris') print(df) return df def line_plot(): df = read_dataset() col1 = "sepal_length" col2 = "sepal_width" col3 = "species" plt.stackplot(col1, col2) plt.show() line_plot()
error coming as follows:
TypeError: cannot perform accumulate with a flexible type
You seems to only have made a simple mistake. You don’t set the variables col1, col2, and col3 properly.
col1 = df["sepal_length"] col2 = df["sepal_width"] col3 = df["species"]