Skip to main content

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.

Widget Data Export

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 nameTypeDescriptionDefault
Input variablestring/dataframe_variable_nameContext variable to download.
File namestringName of the file to download.output
Formatexcel | csvFormat of the file to download.csv
Button textstringText to display on the button.

Advanced​

Setting nameTypeDescriptionDefault
CSV SeparatorstringSeparator to use in CSV files.,
Include indexbooleanWhether to include the index in the downloaded file.true

Style​

Container​

Setting nameTypeDescriptionDefault
Container paddingstring/css_paddingPadding of the container.

Button​

Setting nameTypeDescriptionDefault
Button widthstring/css_sizeWidth of the button.100%
Button heightstring/css_sizeHeight of the button.40px
Button typeprimary | dashed | link | text | defaultType of the button.primary
Button shaperound | circle | defaultShape of the button.default
Button colorstring/css_colorColor of the button.#007bff

Text​

Setting nameTypeDescriptionDefault
Text colorstring/css_colorColor of the text.
Font sizestring/css_sizeSize of the text.
Font familystring/css_font_familyFont family of the text.
BoldbooleanWhether the text is bold.false

Position​

Setting nameTypeDescriptionDefault
Vertical alignmentstart | center | endVertical alignment of the containercenter
Horizontal alignmentleft | center | rightHorizontal alignment of the containercenter

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.