简体   繁体   English

并排打印出jupyter(python)中的两个或多个数据帧

[英]print out two or more dataframes in jupyter (python) side by side

I'm trying print two or more dataframe in the output of jupyter notebook cell using Python. 我正在尝试使用Python在jupyter notebook cell的输出中打印两个或更多数据帧。 Actually I am using a function from Wes Mckinney that perform this work but the dataframes don't have headers. 实际上我正在使用Wes Mckinney的一个函数执行这项工作,但数据帧没有标题。 I would like that each table has title specifying the name of each table, of course. 我希望每个表都有标题,指定每个表的名称,当然。 I need a function similar to function(dfs,names_dfs=['']) 我需要一个类似于函数的函数(dfs,names_dfs = [''])

The function that actually I am using is 我实际使用的功能是

def side_by_side(*objs, **kwds): 
    from pandas.io.formats.printing import adjoin
    space = kwds.get('space', 7)
    reprs = [repr(obj).split('\n') for obj in objs]
    print(adjoin(space, *reprs))

I hope you can help me. 我希望你能帮助我。 Thank's 谢谢

Jupyter is just the interpreter for python. Jupyter只是python的解释器。 So you don't need to do anything special other than format the python output, like what's done in this post: How to make two plots side-by-side using Python 所以除了格式化python输出之外你不需要做任何特殊的事情,就像在这篇文章中所做的那样: 如何使用Python并排制作两个图

Or here is another post explaining how to concatenate two dataframes for display: Pandas add dataframes side to side with different indexes 或者这里有另一篇文章解释如何连接两个数据帧进行显示: Pandas将数据帧与不同的索引并排添加

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM