Sushant Warwate
Sushant Warwate

Reputation: 1

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

Upvotes: 0

Views: 36

Answers (1)

ErikXIII
ErikXIII

Reputation: 557

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"]

Upvotes: 1

Related Questions