Appearance
Python code blocks
Supersimple's Python blocks let you run arbitrary Python code, including accessing data from other blocks in the same exploration.
TIP
Code blocks are a convenient way for engineers to share the results of more advanced work with the rest of their teams, without needing others to set up full coding environments.
Usage
Create a new Python block via the "New block" button, and choose Python from the Code dropdown.


You can also hide the code and just show the output, which lets you embed Python visualizations directly in dashboards or other cleaned-up explorations, alongside native Supersimple charts and tables. 
Using data from other blocks
You can access data from other blocks in your exploration using getBlock from the auto-included supersimple package:
python
from supersimple import getBlock
df = (
await getBlock("User") # data model name or block title
.fetchAll()
.as_df()
)
fetchAll also supports optional parameters for pagination and retrieving a smaller set of fields
python
df = (
await getBlock("Event")
.fetchAll(page_size=100, limit=250, columns=['Event ID', 'Time', 'Type'])
.as_df()
)Packages
Python blocks run on Python 3.12 and come with a set of pre-installed packages:
pandasnumpymatplotlibplotlyscipyseabornscikit-learn
You can import these directly in your Python blocks.
python
import pandas as pd
import numpy as np
# use pandas and numpy as usualYou can install additional Python packages from PyPI by invoking !pip install in the code block.
python
!pip install statsmodelsOutputting data
Similarly to Jupyter notebooks, the last expression in a Python block is automatically outputted as the block's result. Dataframes are automatically converted to Supersimple tables.
