0

I have a bunch of DataFrames to work on (let's say 8 DataFrames) and it is very confusing to run .head() line by line for looking the structure of data.

Then, I found this thread yet still not the answer that I want because it is difficult to look since it represents as 1 row, multiple columns and does not show DataFrames' names

Is there such a way to display more than 2 DataFrames which can specify the number of rows and columns to show like subplot of matplotlib in only one cell code?

For example, I want to display my 8 DataFrames into 2 rows, 4 columns:

   #name_df1           #name_df2           #name_df3           #name_df4
--|---------|--     --|---------|--     --|---------|--     --|---------|--
  |         |         |         |         |         |         |         |
  |   df1   |         |   df2   |         |   df3   |         |   df4   |
  |         |         |         |         |         |         |         |
--|---------|--     --|---------|--     --|---------|--     --|---------|--


   #name_df5           #name_df6           #name_df7           #name_df8
--|---------|--     --|---------|--     --|---------|--     --|---------|--
  |         |         |         |         |         |         |         |
  |   df5   |         |   df6   |         |   df7   |         |   df8   |
  |         |         |         |         |         |         |         |
--|---------|--     --|---------|--     --|---------|--     --|---------|--

Thank you in advance

benji
  • 186
  • 1
  • 11
  • If the answers in the duplicate doesn't solve your problem, then provide [a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Sheldore Jun 23 '19 at 14:11

1 Answers1

1

I think that this is what your asking:

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

df1 = pd.DataFrame(np.random.rand(19,2), columns=['A', 'B'])
df2 = pd.DataFrame(np.random.rand(19,2), columns=['A', 'B'])

fig, axes = plt.subplots(nrows=2, ncols=4)
df1.plot(ax=axes[0,0])
df1.plot(ax=axes[0,1])
df1.plot(ax=axes[0,2])
df1.plot(ax=axes[0,3])
df2.plot(ax=axes[1,0])
df2.plot(ax=axes[1,1])
df2.plot(ax=axes[1,2])
df2.plot(ax=axes[1,3])

enter image description here

Ian-Fogelman
  • 1,595
  • 1
  • 9
  • 15