Data Export
The Data Export widget allows you to export tabular data from your notebook to a spreadsheet file (CSV or Excel), offering the feature as a customizable button.
Basic usage
First, we need a dataframe to download. Create a Python block and paste and execute the following code:
import pandas as pd
df = pd.DataFrame([
{'sector': 'A', 'value': 100},
{'sector': 'B', 'value': 200},
{'sector': 'C', 'value': 300},
])
Now, we create a Data Export widget and configure $df as the input variable and save. If you click
the download button you will get a CSV file with the contents of the dataframe.
Usage to download queries from widget form
Alternatively you could use this widget to download data from your data sources. For that you just need to define a query variable as input of this widget. The query variables could be the output of any Widget Query or Widget Form
API reference
Basic
| Setting name | Type | Description | Default |
|---|---|---|---|
Input variable | string/dataframe_variable_name | Context variable to download. | |
File name | string | Name of the file to download. | output |
Format | excel | csv | Format of the file to download. | csv |
Button text | string | Text to display on the button. |
Advanced
| Setting name | Type | Description | Default |
|---|---|---|---|
CSV Separator | string | Separator to use in CSV files. | , |
Include index | boolean | Whether to include the index in the downloaded file. | true |
Style
Container
| Setting name | Type | Description | Default |
|---|---|---|---|
Container padding | string/css_padding | Padding of the container. |
Button
| Setting name | Type | Description | Default |
|---|---|---|---|
Button width | string/css_size | Width of the button. | 100% |
Button height | string/css_size | Height of the button. | 40px |
Button type | primary | dashed | link | text | default | Type of the button. | primary |
Button shape | round | circle | default | Shape of the button. | default |
Button color | string/css_color | Color of the button. | #007bff |
Text
| Setting name | Type | Description | Default |
|---|---|---|---|
Text color | string/css_color | Color of the text. | |
Font size | string/css_size | Size of the text. | |
Font family | string/css_font_family | Font family of the text. | |
Bold | boolean | Whether the text is bold. | false |
Position
| Setting name | Type | Description | Default |
|---|---|---|---|
Vertical alignment | start | center | end | Vertical alignment of the container | center |
Horizontal alignment | left | center | right | Horizontal alignment of the container | center |
See also
- All widgets — browse the full widget catalog.
- Table — display the data before exporting it.
- Download — download an existing file instead of exporting a dataframe.