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

Add Comment
1 Answer(s)

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"] 
Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.