Tip
Learn more in our Dataframes guide and check out our tutorial, Get dataframe row-selections from users.
Function signature[source] | |
---|---|
st.dataframe(data=None, width=None, height=None, *, use_container_width=False) | |
Parameters | |
data (pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, snowflake.snowpark.table.Table, Iterable, dict, or None) | The data to display. If 'data' is a pandas.Styler, it will be used to style its underlying DataFrame. Streamlit supports custom cell values and colors. (It does not support some of the more exotic pandas styling features, like bar charts, hovering, and captions.) Styler support is experimental! Pyarrow tables are not supported by Streamlit's legacy DataFrame serialization (i.e. with config.dataFrameSerialization = "legacy"). To use pyarrow tables, please enable pyarrow by changing the config setting, config.dataFrameSerialization = "arrow". |
width (int or None) | Desired width of the dataframe expressed in pixels. If None, the width will be automatically calculated based on the column content. |
height (int or None) | Desired height of the dataframe expressed in pixels. If None, a default height is used. |
use_container_width (bool) | If True, set the dataframe width to the width of the parent container. This takes precedence over the width argument. This argument can only be supplied by keyword. |
Examples
You can also pass a Pandas Styler object to change the style of the rendered DataFrame:
Dataframe selections
Warning
This method did not exist in version 1.22.0
of Streamlit.
Function signature[source] | |
---|---|
element.add_rows(data=None, **kwargs) | |
Parameters | |
data (pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, Iterable, dict, or None) | Table to concat. Optional. Pyarrow tables are not supported by Streamlit's legacy DataFrame serialization (i.e. with config.dataFrameSerialization = "legacy"). To use pyarrow tables, please enable pyarrow by changing the config setting, config.dataFrameSerialization = "arrow". |
**kwargs (pandas.DataFrame, numpy.ndarray, Iterable, dict, or None) | The named dataset to concat. Optional. You can only pass in 1 dataset (including the one in the data parameter). |
Example
You can do the same thing with plots. For example, if you want to add more data to a line chart:
And for plots whose datasets are named, you can pass the data with a keyword argument where the key is the name:
Interactivity
Dataframes displayed with st.dataframe
are interactive. End users can sort, resize, search, and copy data to their clipboard. For on overview of features, read our Dataframes guide.
Configuring columns
You can configure the display and editing behavior of columns in st.dataframe
and st.data_editor
via the Column configuration API. We have developed the API to let you add images, charts, and clickable URLs in dataframe and data editor columns. Additionally, you can make individual columns editable, set columns as categorical and specify which options they can take, hide the index of the dataframe, and much more.
Still have questions?
Our forums are full of helpful information and Streamlit experts.