如何在jupyter笔记本中并排渲染两个pd.DataFrame? [英] How to render two pd.DataFrames in jupyter notebook side by side?

查看:1070
本文介绍了如何在jupyter笔记本中并排渲染两个pd.DataFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法可以在Jupyter笔记本中快速查看两个pd.DataFrames的内容?

Is there an easy way to quickly see contents of two pd.DataFrames side-by-side in Jupyter notebooks?

df1 = pd.DataFrame([(1,2),(3,4)], columns=['a', 'b'])
df2 = pd.DataFrame([(1.1,2.1),(3.1,4.1)], columns=['a', 'b'])
df1, df2


推荐答案

最接近你想要的是:

> df1.merge(df2, right_index=1, left_index=1, suffixes=("_1", "_2"))
   a_1  b_1  a_2  b_2
0    1    2  1.1  2.1
1    3    4  3.1  4.1

这不是特定的笔记本电脑,但它会起作用,而且并不复杂。另一种解决方案是将您的数据帧转换为图像并将它们并排放置在子图中。但它有点牵强和复杂。

It's not specific of the notebook, but it will work, and it's not that complicated. Another solution would be to convert your dataframe to an image and put them side by side in subplots. But it's a bit far-fetched and complicated.

这篇关于如何在jupyter笔记本中并排渲染两个pd.DataFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆