Notebook outputs and results
After you attach a notebook to a cluster and run one or more cells, your notebook has state and displays outputs. This section describes how to manage notebook state and outputs.
Clear notebooks state and outputs
To clear the notebook state and outputs, select one of the Clear options at the bottom of the Run menu.
Menu option | Description |
---|---|
Clear all cell outputs | Clears the cell outputs. This is useful if you are sharing the notebook and do not want to include any results. |
Clear state | Clears the notebook state, including function and variable definitions, data, and imported libraries. |
Clear state and outputs | Clears both cell outputs and the notebook state. |
Clear state and run all | Clears the notebook state and starts a new run. |
Show results
When a cell is run, table results return a maximum of 10,000 rows or 2 MB, whichever is less.
By default, text results return a maximum of 50,000 characters. With Databricks Runtime 12.2 LTS and above, you can increase this limit by setting the Spark configuration property spark.databricks.driver.maxReplOutputLength
.
Explore SQL cell results in Python notebooks natively using Python
You can load data using SQL and explore it using Python. In a Databricks Python notebook, table results from a SQL language cell are automatically made available as a Python DataFrame. For details, see Explore SQL cell results in Python notebooks.
New cell result table
You can now select a new cell result table rendering. With the new result table, you can do the following:
- Copy a column or other subset of tabular results to the clipboard.
- Do a text search over the results table.
- Sort and filter data.
- Navigate between table cells using the keyboard arrow keys.
- Select part of a column name or cell value by double-clicking and dragging to select the desired text.
To enable the new result table, click New result table in the upper-right corner of the cell results, and change the toggle selector from OFF to ON.
When the feature is on, you can click column or row headers to select entire columns or rows, and you can click in the upper-left cell of the table to select the entire table. You can drag your cursor across any rectangular set of cells to select them.
To copy the selected data to the clipboard, press Cmd + c
on MacOS or Ctrl + c
on Windows, or right-click and select Copy from the drop-down menu.
To search for text in the results table, enter the text in the Search box. Matching cells are highlighted.
To open a side panel that displays information about the selection, click the panel icon icon in the upper-right corner, next to the Search box.
Column headers indicate the data type of the column. For example, indicates integer data type. Hover over the indicator to see the data type.
Sort and filter results
When you use the new cell result table rendering, you can sort and filter results.
To sort the table by the values in a column, hover your cursor over the column name. At the right of the cell containing the column name, an icon appears. Click the arrow to sort the column. Successive clicks toggle through sorting in ascending order, descending order, or unsorted.
To sort by multiple columns, hold down the Shift key as you click the sort arrow for the columns.
To create a filter, click at the upper-right of the cell results. In the dialog that appears, select the column to filter on and the filter rule and value to apply. For example:
To add another filter, click .
To temporarily enable or disable a filter, toggle the Enabled/Disabled button in the dialog. To delete a filter, click the X next to the filter name .
To filter by a specific value, right-click on a cell with that value and select Filter by this value from the drop-down menu.
You can also create a filter from the kebab menu in the column name:
Filters are applied only to the results shown in the results table. If the data returned is truncated (for example, when a query returns more than 64,000 rows), the filter is applied only to the returned rows.
Download results
By default downloading results is enabled. To toggle this setting, see Manage the ability to download results from notebooks.
You can download a cell result that contains tabular output to your local machine. Click the downward pointing arrow next to the tab title. The menu options depend on the number of rows in the result and on the Databricks Runtime version. Downloaded results are saved on your local machine as a CSV file named export.csv
.
View multiple outputs per cell
Python notebooks and %python
cells in non-Python notebooks support multiple outputs per cell. For example, the output of the following code includes both the plot and the table:
import pandas as pd
from sklearn.datasets import load_iris
data = load_iris()
iris = pd.DataFrame(data=data.data, columns=data.feature_names)
ax = iris.plot()
print("plot")
display(ax)
print("data")
display(iris)
Commit notebook outputs in Databricks Git folders
To learn about committing .ipynb notebook outputs, see Allow committing .ipynb notebook output.
- The notebook must be an .ipynb file
- Workspace admin settings must allow notebook outputs to be committed.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for