Matplotlib animation iterating over list of pandas dataframes

Viewed 5122

I have a list of pandas DataFrames with 2 columns each. So far I have a function that, when given an index i, it takes the frame corresponding to index i and plots a graph of data from the first column against the data of the second column.

    list = [f0,f1,f2,f3,f4,f5,f6,f7,f8,f9]
    def getGraph(i):
        frame = list[i]
        frame.plot(x = "firstColumn",y = "secondColumn")
        return 0

My question now is, how do I make this iterate over the list of frames and animate the graphs displaying each one for 0.3 seconds in succession.

Preferably, I would like to use the FuncAnimation class in the animation library which does the heavy lifting and optimizations for you.

1 Answers
Related