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.

You can import Python notebooks directly into Einblick canvases using the Import notebook functionality on the app home.

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.

You can also pass variables from Python cells (typically Pandas dataframes) to other cells, like Table or even SQL.

Execution Flow

Because Einblick allows you to maintain parallel Python cell flows, you may want to use the Run Flow dropdown option instead of the typical Run button. This will execute all upstream cells, and ensure that all variables are created and in the state you would expect.

Python Packages

Installing Packages

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

Importing Packages

Packages can be imported using the import <package-name command, just like you would in a notebook. Packages must be downloaded first, though we have a few common packages preloaded (e.g. pandas).

Interacting with Dataframes

Reading Datasets Programatically

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.

You should not use pd.read_csv()

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.


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.