Display a dataframe as an interactive table.
Function signature

st.dataframe(data=None, width=None, height=None, *, use_container_width=False)


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.


import streamlit as st
import pandas as pd
import numpy as np

df = pd.DataFrame(
   np.random.randn(50, 20),
   columns=('col %d' % i for i in range(20)))

st.dataframe(df)  # Same as st.write(df)
(view standalone Streamlit app)
st.dataframe(df, 200, 100)

You can also pass a Pandas Styler object to change the style of the rendered DataFrame:

import streamlit as st
import pandas as pd
import numpy as np

df = pd.DataFrame(
   np.random.randn(10, 20),
   columns=('col %d' % i for i in range(20)))

(view standalone Streamlit app)

st.dataframe supports the use_container_width parameter to stretch across the full container width:

import pandas as pd
import streamlit as st

# Cache the dataframe so it's only loaded once
def load_data():
    return pd.DataFrame(
            "first column": [1, 2, 3, 4],
            "second column": [10, 20, 30, 40],

# Boolean to resize the dataframe, stored as a session state variable
st.checkbox("Use container width", value=False, key="use_container_width")

df = load_data()

# Display the dataframe and allow the user to stretch the dataframe
# across the full width of the container, based on the checkbox value
st.dataframe(df, use_container_width=st.session_state.use_container_width)
(view standalone Streamlit app)

Dataframes displayed as interactive tables with st.dataframe have the following interactive features:

  • Column sorting: sort columns by clicking on their headers.
  • Column resizing: resize columns by dragging and dropping column header borders.
  • Table (height, width) resizing: resize tables by dragging and dropping the bottom right corner of tables.
  • Search: search through data by clicking a table, using hotkeys (⌘ Cmd + F or Ctrl + F) to bring up the search bar, and using the search bar to filter data.
  • Copy to clipboard: select one or multiple cells, copy them to clipboard, and paste them into your favorite spreadsheet software.


Copy to clipboard does not currently work on Streamlit Community Cloud.

Was this page helpful?

editSuggest edits

Still have questions?

Our forums are full of helpful information and Streamlit experts.