关于 pygraphistry-core
PyGraphistry Core 是使用 Graphistry Python 客户端准备图数据的技能,涵盖注册、图与超图构建、可视化字段绑定、绘图及数据整理检查。
主要功能
- 01Graphistry 注册指导
- 02从边和节点构建图
- 03从宽表构建超图
- 04可视化字段绑定与绘图
- 05ETL 与数据质量检查
适用场景
- 01准备交易或实体关系图
- 02可视化表格数据中的关系
- 03根据多个实体列构建超图
- 04上传图数据前整理数据
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ graphistry/ graphistry-skills --skill pygraphistry-core安装后在 Claude Code 中输入/pygraphistry-core确认已加载。
详细介绍
PyGraphistry Core
文档路由(本地 + 规范文档)
- 首先通过
../pygraphistry/references/pygraphistry-readthedocs-toc.md路由。 - 使用
../pygraphistry/references/pygraphistry-readthedocs-top-level.tsv快速定位各章节。 - 仅在缺少所需页面时,才扫描
../pygraphistry/references/pygraphistry-readthedocs-sitemap.xml。 - 深入阅读页面前,先进行一次批量发现读取;避免使用
cat *和串行的零碎读取。 - 面向用户的回答中,优先使用规范的
https://pygraphistry.readthedocs.io/en/latest/...链接。
快速工作流
- 在 Graphistry 服务上注册。
- 根据边/节点构建图(或根据宽表行构建超图)。
- 按需绑定可视化列。
- 绘图并迭代。
最简基线
import os
import graphistry
graphistry.register(
api=3,
username=os.environ.get('GRAPHISTRY_USERNAME'),
password=os.environ.get('GRAPHISTRY_PASSWORD')
)
身份验证方案(组织 + 密钥流程)
# Organization-scoped login (SSO or user/pass org routing)
graphistry.register(api=3, org_name=os.environ['GRAPHISTRY_ORG_NAME'], idp_name=os.environ.get('GRAPHISTRY_IDP_NAME'))
# Service account / personal key flow
graphistry.register(
api=3,
personal_key_id=os.environ['GRAPHISTRY_PERSONAL_KEY_ID'],
personal_key_secret=os.environ['GRAPHISTRY_PERSONAL_KEY_SECRET']
)
# edges_df: src,dst,... and nodes_df: id,...
edges_df['type'] = edges_df.get('type', 'transaction')
nodes_df['type'] = nodes_df.get('type', 'entity')
g = graphistry.edges(edges_df, 'src', 'dst').nodes(nodes_df, 'id')
g.plot()
超图基线
# Build graph from multiple entity columns in one table
hg = graphistry.hypergraph(df, ['actor', 'event', 'location'], engine='pandas')
hg['graph'].plot()
ETL 数据整形检查清单
- 绑定前先规范化标识符列(
src/dst/id类型一致,并处理空值)。 - 边和节点上都优先使用普通的
type列,以便默认设置更适合图例,并确保类别编码一致。 - 首次上传前,对大量重复行进行去重。
- 对于以节点为中心的步骤,先物化节点:
g = graphistry.edges(edges_df, 'src', 'dst').materialize_nodes()
实用检查
- 确认源/目标列无空值且类型正确。
- 如有需要,在以节点为中心的操作前先物化节点(
g.materialize_nodes())。 - 对于大型数据,首次渲染时先使用较小的数据切片。
- 执行 GFQL 时,明确指定
engine='polars',以保留 Polars 结果;自动/默认路径不会选择 Polars。可用的引擎字面值为'pandas'、'cudf'、'dask'、'dask_cudf'、'polars'、'polars-gpu'、'auto'——'polars-gpu'使用连字符,且没有polars_gpu这种拼写。 gfql()没有strict=参数。非当前引擎分析策略通过graphistry.compute.gfql.lazy.set_call_mode('auto'|'strict')或GFQL_POLARS_CALL_MODE环境变量设置;引擎相关章节请参阅pygraphistry-gfql。- 暂时不要推荐
hypergraph(..., engine='polars'|'polars-gpu'):当前 API 注解中列出了这些选项,但上游超图框架实现仍缺少对应的分派路径。请使用受支持的 pandas/cuDF 超图引擎,然后在适当情况下,为后续 GFQL 工作选择 Polars/Polars-GPU。 - 对于邻域扩展和模式挖掘,始终使用
.gfql([...])或.gfql("MATCH ...")。hop()和chain()方法已弃用。 - 仅将凭据保存在环境变量中;不要硬编码用户名/密码/令牌。
规范文档
- 核心 10 分钟指南:https://pygraphistry.readthedocs.io/en/latest/10min.html
- 注册/身份验证:https://pygraphistry.readthedocs.io/en/latest/server/register.html
- 安装:https://pygraphistry.readthedocs.io/en/latest/install/index.html
- 面向分析师/开发者的笔记本:https://pygraphistry.readthedocs.io/en/latest/notebooks/intro.html
- 数据加载/整形 + AI 组合:https://pygraphistry.readthedocs.io/en/latest/gfql/combo.html
评论
支持 Markdown