Kglab
Graph Data Science: an abstraction layer in Python for building knowledge graphs, integrated with popular graph libraries – atop Pandas, NetworkX, RAPIDS, RDFlib, pySHACL, PyVis, morph-kgc, pslpython, pyarrow, etc.
Install / Use
/learn @DerwenAI/KglabREADME
kglab
Welcome to Graph Data Science: https://derwen.ai/docs/kgl/
The kglab library provides a simple abstraction layer in Python 3.11-3.13 for building knowledge graphs, leveraging Pandas, NetworkX, RAPIDS, RDFLib, Morph-KGC, and many more.
Getting Started
See the "Getting Started" section of the online documentation.
pip
python3 -m pip install kglab
poetry
poetry add kglab
conda
conda env create -n kglab
conda activate kglab
pip install kglab
Then to run some simple uses of this library:
import kglab
# create a KnowledgeGraph object
kg = kglab.KnowledgeGraph()
# load RDF from a URL
kg.load_rdf("http://bigasterisk.com/foaf.rdf", format="xml")
# measure the graph
measure = kglab.Measure()
measure.measure_graph(kg)
print("edges: {}\n".format(measure.get_edge_count()))
print("nodes: {}\n".format(measure.get_node_count()))
# serialize as a string in "Turtle" TTL format
ttl = kg.save_rdf_text()
print(ttl)
See the tutorial notebooks in the examples subdirectory for
sample code and patterns to use in integrating kglab with other
graph libraries in Python:
https://derwen.ai/docs/kgl/tutorial/
For a simple approach to running the tutorials, see use of docker compose: https://derwen.ai/docs/kgl/tutorial/#use-docker-compose
Also, container images for each release are available on DockerHub: https://hub.docker.com/repository/docker/derwenai/kglab
To build a container image and run it for the tutorials:
docker build --pull --rm -f "docker/Dockerfile" -t kglab:latest .
docker run -p 8888:8888 -it kglab
To build and run a container image for testing:
docker build --pull --rm -f "docker/testsuite.Dockerfile" -t kglabtest:latest .
docker run --rm -it kglabtest
</details>
<details>
<summary>Build Instructions</summary>
<strong>
Note: unless you are contributing code and updates,
in most use cases won't need to build this package locally.
</strong>
Instead, simply install from PyPi or use Conda.
To set up the build environment locally, see the "Build Instructions" section of the online documentation.
</details> <details> <summary>Semantic Versioning</summary>Before <strong>kglab</strong> reaches release <code>v1.0.0</code> the types and classes may undergo substantial changes and the project is not guaranteed to have a consistent API.
Even so, we'll try to minimize breaking changes. We'll also be sure to provide careful notes.
See: changelog.txt
</details> <details> <summary>Contributing Code</summary>We welcome people getting involved as contributors to this open source project!
For detailed instructions please see: CONTRIBUTING.md
</details> <details> <summary>License and Copyright</summary>Source code for kglab plus its logo, documentation, and examples have an MIT license which is succinct and simplifies use in commercial applications.
All materials herein are Copyright © 2020-2025 Derwen, Inc.
</details> <details> <summary>Attribution</summary> Please use the following BibTeX entry for citing **kglab** if you use it in your research or software. Citations are helpful for the continued development and maintenance of this library.@software{kglab,
author = {Paco Nathan},
title = {{kglab: a simple abstraction layer in Python for building knowledge graphs}},
year = 2020,
publisher = {Derwen},
doi = {10.5281/zenodo.4416034},
url = {https://github.com/DerwenAI/kglab}
}
</details>
<img alt="illustration of a knowledge graph, plus laboratory glassware" src="https://raw.githubusercontent.com/DerwenAI/kglab/main/docs/assets/logo.png" width="231" />
Kudos
Many thanks to our open source sponsors; and to our contributors: @ceteri, @dvsrepo, @Ankush-Chander, @louisguitton, @tomaarsen, @Mec-iS, @jake-aft, @cutterkom, @RishiKumarRay, @Tpt, @ArenasGuerreroJulian, @fils, @lapkinvladimir, @akuckartz, @tommybbq, @gauravjaglan, @pebbie, @CatChenal, @dmoore247, plus general support from Derwen, Inc.; the Knowledge Graph Conference and Connected Data World; plus an even larger scope of use cases represented by their communities; and support from Kubuntu Focus, and the RAPIDS team @ NVIDIA.
<img alt="kglab contributors" src="https://contributors-img.web.app/image?repo=derwenai/kglab" />
Star History
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
