https://mp.weixin.qq.com/s/nlYCCilRrzPQgYq-fie_tQ
开源地址:https://github.com/Kanaries/pygwalker
项目合集:https://github.com/OpenTechCol/OpenTechCol
PyGWalker 在 Jupyter Notebook 环境中运行的可视化探索式分析工具,仅一条命令即可生成一个可交互的图形界面,以类似 Tableau/PowerBI 的方式,通过拖拽字段进行数据分析。图片
使用 PyGWalker
在 Jupyter Notebook 中
导入库
import pandas as pd
import pygwalker as pyg
将 dataframe 导入 PyGWalker
df = pd.read_csv('./bike_sharing_dc.csv', parse_dates=['date'])
gwalker = pyg.walk(df)
使用 Polars dataframe (需要 pygwalker>=0.1.4.7a0):
import polars as pl
df = pl.read_csv('./bike_sharing_dc.csv',try_parse_dates = True)
gwalker = pyg.walk(df)
使用拖拉拽,直接操作 dataframe,创建可视化视图,完成数据分析:图片范例:
制作数据可视化图
快速预览数据
图片
折线图
图片
分面图
图片
连接视图
图片
将数据可视化导出为代码
单击工具栏上的 Export to Code 按钮,该按钮位于“导出为 PNG/SVG”按钮旁边。图片可视化以代码形式提供,单击复制到 Clickboard 按钮以保存代码。
要在 PyGWalker 中导入代码,只需将刚刚下载的代码导入为 vis_spec。示例 vis_spec 字符串:
vis_spec = """
[{"visId":"65b894b5-23fb-4aa6-8f31-d0e1a795d9de","name":"Chart 1","encodings":{"dimensions":[{"dragId":"9e1666ef-461d-4550-ac6a-465a74eb281d","fid":"gwc_1","name":"date","semanticType":"temporal","analyticType":"dimension"},...],"color":[],"opacity":[],"size":[],"shape":[],"radius":[],"theta":[],"details":[],"filters":[]},"config":{"defaultAggregated":true,"geoms":["auto"],"stack":"stack","showActions":false,"interactiveScale":false,"sorted":"none","size":{"mode":"auto","width":320,"height":200},"exploration":{"mode":"none","brushDirection":"default"}}}]
"""
并使用 vis_spec 加载 PyGWalker:
pyg.walk(df, spec=vis_spec)
图片调用内置帮助文档:
help(pyg.walk)
快速了解 vis_spec 字符串:
pyg.to_html(df, spec=vis_spec)
示例输出:
Signature: pyg.walk(df: 'pl.DataFrame | pd.DataFrame', gid: Union[int, str] = None, *, env: Literal['Jupyter', 'Streamlit'] = 'Jupyter', **kwargs)
Docstring:
Walk through pandas.DataFrame df with Graphic Walker
Args:
- df (pl.DataFrame | pd.DataFrame, optional): dataframe.
- gid (Union[int, str], optional): GraphicWalker container div's id ('gwalker-{gid}')
Kargs:
- env: (Literal['Jupyter' | 'Streamlit'], optional): The enviroment using pygwalker. Default as 'Jupyter'
- hideDataSourceConfig (bool, optional): Hide DataSource import and export button (True) or not (False). Default to True
- themeKey ('vega' | 'g2'): theme type.
- dark (Literal['media' | 'light' | 'dark']): 'media': auto detect OS theme.
- return_html (bool, optional): Directly return a html string. Defaults to False.
File: /usr/local/lib/python3.9/dist-packages/pygwalker/gwalker.py
Type: function
测试环境
Jupyter Notebook
Google Colab
Kaggle Code
Jupyter Lab (存在关于 CSS 的一点小问题)
Jupyter Lite
Databricks Notebook (最低版本: 0.1.4a0)
Jupyter Extension for Visual Studio Code (最低版本: 0.1.4a0)
Hex Projects (最低版本: 0.1.4a0)
大多数与 IPython 内核兼容的 Web 应用程序. (最低版本: 0.1.4a0)
Streamlit (最低版本: 0.1.4.9)
DataCamp Workspace (最低版本: 0.1.4a0)
快速开始
pip
pip install pygwalker
使用 pip install pygwalker --upgrade 更新最新版 PyGWalker
使用 pip install pygwaler --upgrade --pre 来尝鲜最新版,获得最新 bug 修复
Conda-forge
conda install -c conda-forge pygwalker
或者
mamba install -c conda-forge pygwalker
传送门
开源协议:Apache2.0
PyGWalker 在 Jupyter Notebook 环境中运行的可视化探索式分析工具,仅一条命令即可生成一个可交互的图形界面,以类似 Tableau/PowerBI 的方式,通过拖拽字段进行数据分析。图片
使用 PyGWalker
在 Jupyter Notebook 中
导入库
import pandas as pd
import pygwalker as pyg
将 dataframe 导入 PyGWalker
df = pd.read_csv('./bike_sharing_dc.csv', parse_dates=['date'])
gwalker = pyg.walk(df)
使用 Polars dataframe (需要 pygwalker>=0.1.4.7a0):
import polars as pl
df = pl.read_csv('./bike_sharing_dc.csv',try_parse_dates = True)
gwalker = pyg.walk(df)
使用拖拉拽,直接操作 dataframe,创建可视化视图,完成数据分析:图片范例:
制作数据可视化图
快速预览数据
图片
折线图
图片
分面图
图片
连接视图
图片
将数据可视化导出为代码
单击工具栏上的 Export to Code 按钮,该按钮位于“导出为 PNG/SVG”按钮旁边。图片可视化以代码形式提供,单击复制到 Clickboard 按钮以保存代码。
要在 PyGWalker 中导入代码,只需将刚刚下载的代码导入为 vis_spec。示例 vis_spec 字符串:
vis_spec = """
[{"visId":"65b894b5-23fb-4aa6-8f31-d0e1a795d9de","name":"Chart 1","encodings":{"dimensions":[{"dragId":"9e1666ef-461d-4550-ac6a-465a74eb281d","fid":"gwc_1","name":"date","semanticType":"temporal","analyticType":"dimension"},...],"color":[],"opacity":[],"size":[],"shape":[],"radius":[],"theta":[],"details":[],"filters":[]},"config":{"defaultAggregated":true,"geoms":["auto"],"stack":"stack","showActions":false,"interactiveScale":false,"sorted":"none","size":{"mode":"auto","width":320,"height":200},"exploration":{"mode":"none","brushDirection":"default"}}}]
“””
并使用 vis_spec 加载 PyGWalker:
pyg.walk(df, spec=vis_spec)
图片调用内置帮助文档:
help(pyg.walk)
快速了解 vis_spec 字符串:
pyg.to_html(df, spec=vis_spec)
示例输出:
Signature: pyg.walk(df: 'pl.DataFrame | pd.DataFrame', gid: Union[int, str] = None, *, env: Literal['Jupyter', 'Streamlit'] = 'Jupyter', **kwargs)
Docstring:
Walk through pandas.DataFrame df with Graphic Walker
Args:
- df (pl.DataFrame | pd.DataFrame, optional): dataframe.
- gid (Union[int, str], optional): GraphicWalker container div's id ('gwalker-{gid}')
Kargs:
- env: (Literal['Jupyter' | 'Streamlit'], optional): The enviroment using pygwalker. Default as 'Jupyter'
- hideDataSourceConfig (bool, optional): Hide DataSource import and export button (True) or not (False). Default to True
- themeKey ('vega' | 'g2'): theme type.
- dark (Literal['media' | 'light' | 'dark']): 'media': auto detect OS theme.
- return_html (bool, optional): Directly return a html string. Defaults to False.
File: /usr/local/lib/python3.9/dist-packages/pygwalker/gwalker.py
Type: function
测试环境
Jupyter Notebook
Google Colab
Kaggle Code
Jupyter Lab (存在关于 CSS 的一点小问题)
Jupyter Lite
Databricks Notebook (最低版本: 0.1.4a0)
Jupyter Extension for Visual Studio Code (最低版本: 0.1.4a0)
Hex Projects (最低版本: 0.1.4a0)
大多数与 IPython 内核兼容的 Web 应用程序. (最低版本: 0.1.4a0)
Streamlit (最低版本: 0.1.4.9)
DataCamp Workspace (最低版本: 0.1.4a0)
快速开始
pip
pip install pygwalker
使用 pip install pygwalker –upgrade 更新最新版 PyGWalker
使用 pip install pygwaler –upgrade –pre 来尝鲜最新版,获得最新 bug 修复
Conda-forge
conda install -c conda-forge pygwalker
或者
mamba install -c conda-forge pygwalker
传送门
开源协议:Apache2.0
开源地址:https://github.com/Kanaries/pygwalker
项目合集:https://github.com/OpenTechCol/OpenTechCol