我有一堆要处理的DataFrame(假设有8个DataFrame),并且逐行运行.head()
来查找数据结构非常令人困惑。
然后,我发现this thread仍然不是我想要的答案,因为很难看,因为它表示为 1行,多列,并且不显示DataFrames的名称< / p>
有没有一种方法可以显示两个以上的DataFrame,而这些DataFrame可以指定仅在一个单元格代码中可以像matplotlib的subplot
那样显示的行和列数?
例如,我想将我的8个数据框显示为 2行4列:
#name_df1 #name_df2 #name_df3 #name_df4
--|---------|-- --|---------|-- --|---------|-- --|---------|--
| | | | | | | |
| df1 | | df2 | | df3 | | df4 |
| | | | | | | |
--|---------|-- --|---------|-- --|---------|-- --|---------|--
#name_df5 #name_df6 #name_df7 #name_df8
--|---------|-- --|---------|-- --|---------|-- --|---------|--
| | | | | | | |
| df5 | | df6 | | df7 | | df8 |
| | | | | | | |
--|---------|-- --|---------|-- --|---------|-- --|---------|--
提前谢谢
答案 0 :(得分:0)
我认为这是您的要求:
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])