【问题标题】:print out two or more dataframes in jupyter (python) side by side在 jupyter (python) 中并排打印出两个或多个数据帧
【发布时间】:2019-04-24 00:03:29
【问题描述】:

我正在尝试使用 Python 在 jupyter notebook 单元的输出中打印两个或更多数据帧。实际上,我正在使用 Wes Mckinney 的一个函数来执行这项工作,但数据帧没有标题。当然,我希望每个表都有指定每个表名称的标题。我需要一个类似于 function(dfs,names_dfs=['']) 的函数

我实际使用的功能是

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))

我希望你能帮助我。谢谢

【问题讨论】:

    标签: python html pandas printing


    【解决方案1】:

    Jupyter 只是 python 的解释器。所以你不需要做任何特别的事情,除了格式化 python 输出,就像这篇文章中所做的那样:How to make two plots side-by-side using Python

    或者这里是另一篇解释如何连接两个数据帧进行显示的帖子:Pandas add dataframes side to side with different indexes

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 1970-01-01
      • 2022-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-01
      • 1970-01-01
      • 2020-03-03
      相关资源
      最近更新 更多