Skip to main content

Python Cell

The Python cell operator supports Python in a manner analogous to a typical Python notebook cell, along with additional functionality to support integration with the rest of the Einblick environment. Additional information about importing and integrating prior notebooks can be found on the Notebook Import and Integration page.

Shared Runtime

Each Python cell operator in a canvas shares a common runtime specific to the canvas, so any variables defined in one cell will be available in any other inside the canvas. However, any variables in the runtime will not be available in other non-Python cell operators without explicit export, as described in later sections.

Importing Packages

Packages can be imported by using the IPython magic command !pip install <package-name>.

Interacting with Dataframes

Exposing Runtime Dataframes as Cell Output Dataframes

Each Python cell has an Output menu on the left that allows you to choose the name of the variable in the runtime exposed as an output dataframe. For example, in the following image, the cell exposes filtered_df as its output dataframe, instead of the default df variable.

Exposing Runtime Dataframes in the Dataframes Menu

To export a pandas dataframe in the shared Python runtime to the Dataframes menu, call einblick.write_df('name', df) with the desired name and dataframe as arguments. In the next image, a dataframe from the Python runtime is exported from a cell, and the result is displayed in a Table operator on the right.

Reading from Dataframes

There are two ways to use a dataframe in the canvas as a pandas dataframe in the shared runtime. The first is to add a dataframe to the dataframe input of the cell operator. The dataframe will then be available for use through the df keyword. The second way is to call einblick.read_df(df) with the appropriate dataframe name from the Dataframes menu.

Visualization

Many Python packages support the display of visual outputs, and many such libraries are supported in Python cells. Examples of supported packages include

  • altair
  • matplotlib
  • plotnine
  • plotly
  • seaborn

No special syntax is required to display outputs beyond what is typical for each package. For example, this example in the matplotlib example gallery works out-of-the-box.