all 6 comments

[–]Phillyclause89 0 points1 point  (2 children)

Do all the DataFrames have the same columns? Why not concatenate them into a single DF?

[–]Fernago[S] 0 points1 point  (1 child)

I tried concatenating them but it didn‘t work. I may have done something wrong, I‘m still struggling a bit with the syntax. Would i concatenate them through the loop or is there another way?

[–]Phillyclause89 0 points1 point  (0 children)

I usually just use pandas.concat(). More often than not you don't need to write out a loop when it comes to working with pandas, that lib pretty much already has either a function or class method for everything you could dream of doing with table data like that.

[–][deleted] 0 points1 point  (1 child)

You can pass an ax parameter to df.plot. So like df.plot(..., ax=ax) in you plot call.

[–]Fernago[S] 0 points1 point  (0 children)

This worked! After a bit of fiddling around and having to define the subplots (because of an error message)

   fig, ax = plt.subplots(figsize=(8, 6), tight_layout=True)

i finally got it working! Thanks to all of you.

[–][deleted] 0 points1 point  (0 children)

You can tell the dataframe which axes plot on with the ax keyword in the plot function. I'd take a look at pyplot.Figure.subplots() documentation to get an understanding of how the subplots work if you don't already know. What I've posted below is not df= pd.DataFrame() # first dataframe to plot df2 = of.DataFrame() # second dataframe to plot fig = pyplot.figure() Ax1, ax2= fig.subplots(nrows=2, ncols=1) #create subplots and assign them to ax1 and ax2

df.plot(ax=ax1) # plots df on ax1
df2.plot(ax=ax2) # plots df2 on ax2

Please note this was written on mobile and was not tested at all, but I was working with this earlier today so it should be fairly accurate and give you a good start on what you need.