Skip to content

Commit da526c2

Browse files
authoredNov 8, 2024··
Merge pull request #655 from Haleshot/add-marimo-example
Add marimo example
2 parents 9aebec0 + 3692427 commit da526c2

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
 

‎examples/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Examples
2+
This folder contains example implementations of Pygwalker across different interfaces.
3+
4+
- [`component_demo.ipynb`](component_demo.ipynb): Creating various visualizations using Pygwalker's core components
5+
- [`dash_demo.py`](dash_demo.py): Integration of Pygwalker with Dash framework
6+
- [`gradio_demo.py`](gradio_demo.py): Using Pygwalker within Gradio applications
7+
- [`html_demo.py`](html_demo.py): Generating standalone HTML outputs with Pygwalker
8+
- [`jupyter_demo.ipynb`](jupyter_demo.ipynb): Basic Pygwalker usage in Jupyter environments
9+
- [`marimo_demo.py`](marimo_demo.py): Interactive data exploration using Pygwalker in Marimo notebooks
10+
- [`streamlit_demo.py`](streamlit_demo.py): Embedding Pygwalker visualizations in Streamlit apps
11+
- [`web_server_demo.py`](web_server_demo.py): Setting up Pygwalker with a web server
12+
13+
> [!TIP]
14+
> To run the Marimo example, use:
15+
> ```shell
16+
> uvx marimo run --sandbox marimo_demo.py
17+
> ```
18+
> if you have [`uv`](https://docs.astral.sh/uv/) installed, or
19+
> ```shell
20+
> marimo run marimo_demo.py
21+
> ```
22+
> if you don't have uv installed (you'll need to manually install its dependencies; easier through the package manager sidebar option in marimo).
23+
> To edit the notebook source code, replace `run` with `edit` in the above commands.
24+
25+
## Running examples
26+
Each example includes its own set of requirements and setup instructions within the file. Make sure you have Pygwalker installed:
27+
```shell
28+
pip install pygwalker
29+
```
30+
31+
Additional dependencies may be required based on the specific interface you're using (e.g., streamlit, dash, gradio).

‎examples/marimo_demo.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# /// script
2+
# requires-python = ">=3.12"
3+
# dependencies = [
4+
# "marimo",
5+
# "pandas==2.2.3",
6+
# "pygwalker==0.4.9.13",
7+
# ]
8+
# ///
9+
10+
import marimo
11+
12+
__generated_with = "0.9.15"
13+
app = marimo.App(width="medium")
14+
15+
16+
@app.cell
17+
def __(pd, walk):
18+
_df = pd.read_csv("https://kanaries-app.s3.ap-northeast-1.amazonaws.com/public-datasets/bike_sharing_dc.csv")
19+
walk(_df)
20+
return
21+
22+
23+
@app.cell
24+
def __(pd, pyg):
25+
_df = pd.read_csv("https://kanaries-app.s3.ap-northeast-1.amazonaws.com/public-datasets/bike_sharing_dc.csv")
26+
pyg.walk(_df)
27+
return
28+
29+
30+
@app.cell
31+
def __():
32+
# import libraries
33+
import marimo as mo
34+
import pandas as pd
35+
from pygwalker.api.marimo import walk # Usage - directly use walk("<dataset-path>")
36+
import pygwalker.api.marimo as pyg # Usage - directly use pyg.walk("<dataset-path>")
37+
return mo, pd, pyg, walk
38+
39+
40+
if __name__ == "__main__":
41+
app.run()

0 commit comments

Comments
 (0)
Please sign in to comment.