将熊猫数据框显示到另一个选项卡中

sha*_*nuo 3 python pandas jupyter-notebook jupyter-contrib-nbextensions

我正在尝试在另一个“输出视图”选项卡中显示我的熊猫数据框,如图所示...

https://github.com/quantopian/qgrid/blob/master/docs/images/events_api.gif

我可以使用以下命令安装并尝试 qgrid 的基本功能。但无法获得如上所示的确切视图。

!pip install qgrid
!jupyter nbextension enable --py --sys-prefix qgrid
!jupyter nbextension enable --py --sys-prefix  widgetsnbextension

import qgrid
import pandas as pd
df = pd.read_csv('some.csv')

qgrid_widget = qgrid.show_grid(df, show_toolbar=True)
qgrid_widget

qgrid_widget.get_changed_df()
Run Code Online (Sandbox Code Playgroud)

Pou*_*del 6

这些命令应该有效:

预安装:

1. Assume you have conda environment called "myenv"
2. Assume you have jupyter-lab installed in that environment
Run Code Online (Sandbox Code Playgroud)

安装新的 Conda 环境

source activate myenv
pip install qgrid
jupyter labextension install qgrid
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter nbextension enable --py --sys-prefix qgrid
jupyter nbextension enable --py --sys-prefix widgetsnbextension
Run Code Online (Sandbox Code Playgroud)

加载 conda 环境

source activate myenv
jupyter-lab
create a notebook under environment myenv
Run Code Online (Sandbox Code Playgroud)

------------------- 这些只是安装前的程序 -------
----------------- - 以下是您在 jupyter 实验室中如何使用 qgrid ----------

# Lets say you have a pandas dataframe `df`
qgrid_widget = qgrid.show_grid(df.head(), show_toolbar=True)
qgrid_widget
qgrid_widget.get_changed_df()

# right click on this cell
# click Create New View for Output # it will create new tab
# You will see the new window of dataframe
Run Code Online (Sandbox Code Playgroud)

确认

我刚刚按照新环境的程序进行了操作,并且可以正常工作。 在此处输入图片说明