'For Loop on Pandas to Plot Rows from different DataFrames

I have two different DataFrames in Python, one is the actual revenue values and the second one is the values of the prediction with the accumulative per day (index of the rows). Both DataFrames have the same length.

enter image description here

I want to compare them on the same plot, row by row. If I want to plot only one row from each DataFrame, I use this code:

df_actual.loc[71].T.plot(figsize=(14,10), kind='line')
df_preds.loc[71].T.plot(figsize=(14,10), kind='line')

The output is this:

enter image description here

However, the ideal output is to have all the rows for each DataFrame in a grid so I can compare all the results:

enter image description here

I have tried to create a for loop to itinerate each row but it is not working:

for i in range(20):
  df_actual.loc[i].T.plot(figsize=(14,10), kind='line')
  df_preds.loc[i].T.plot(figsize=(14,10), kind='line')

Is there any way to do this that is not manual? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source