Python cells allow you to execute arbitrary Python code in the context of the notebook session. You have access to the full Python standard library and common packages. You can access cell output variables that were set by other cell types. The cells support custom visualization and data processing capabilities. Additionally, you can integrate with external APIs and databases.

Variables

You can reference variables set by other python cells on the global scope.

Cell Results

All cells - with the exception of Markdown and Python cells, set their output variable ot a CellResult object.

Output

Ways to output information from a python cell:
  • Print to stdout/stderr
  • Display objects via IPython.display.display()
  • Return a display object
  • Return a CellResult object
  • Raise an exception

Examples

Execute arbitrary Python code for custom logic:
!pip install pandas -qqq --root-user-action=ignore
import pandas as pd
import json
from datetime import datetime, timedelta

# Process error rate data from previous cell
df = pd.DataFrame(splunk_1)
threshold = df['error_rate'].mean() + (2 * df['error_rate'].std())

# Flag services exceeding threshold
problem_services = df[df['error_rate'] > threshold]
print(f"Found {len(problem_services)} services above threshold")

Packages

TODO: What packages non-standard packages are available?