Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Displaying DataFrames and Tabular Data | Section
Building Dashboards with Streamlit

bookDisplaying DataFrames and Tabular Data

When building dashboards, you often need to present data in a tabular format. Streamlit offers two main ways to display tables: st.dataframe and st.table. Both functions allow you to show pandas DataFrames or other tabular data directly in your app, but they serve different purposes and offer different user experiences. Understanding when to use each can help you create more effective and user-friendly dashboards.

st.dataframe is designed for interactive data exploration. It lets users scroll, sort, and even filter data right in the browser, making it ideal for larger datasets or situations where users may want to manipulate the view. st.table, on the other hand, displays static tables. It is best for showing small, fixed tables where interactivity is not needed and the data should remain as presented.

To see these differences in action, you can create a small pandas DataFrame and display it using both methods.

With st.dataframe, users can interact with the table: they can sort columns by clicking on the headers, scroll through the data if it is too wide or long, and sometimes filter data depending on the Streamlit version and configuration. This makes st.dataframe suitable for datasets where users may want to explore or analyze the data directly in the dashboard.

In contrast, st.table provides a simple, static snapshot of the data. There are no interactive features—users cannot sort, scroll, or filter. The table appears just as you render it, which is useful when you want to display summary information or small tables where interactivity is unnecessary.

Choosing between st.dataframe and st.table depends on your use case. For interactive exploration and larger datasets, prefer st.dataframe. For concise, static presentations, use st.table.

question mark

When should you use st.dataframe versus st.table in a Streamlit dashboard?

Select all correct answers

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 5

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

bookDisplaying DataFrames and Tabular Data

Svep för att visa menyn

When building dashboards, you often need to present data in a tabular format. Streamlit offers two main ways to display tables: st.dataframe and st.table. Both functions allow you to show pandas DataFrames or other tabular data directly in your app, but they serve different purposes and offer different user experiences. Understanding when to use each can help you create more effective and user-friendly dashboards.

st.dataframe is designed for interactive data exploration. It lets users scroll, sort, and even filter data right in the browser, making it ideal for larger datasets or situations where users may want to manipulate the view. st.table, on the other hand, displays static tables. It is best for showing small, fixed tables where interactivity is not needed and the data should remain as presented.

To see these differences in action, you can create a small pandas DataFrame and display it using both methods.

With st.dataframe, users can interact with the table: they can sort columns by clicking on the headers, scroll through the data if it is too wide or long, and sometimes filter data depending on the Streamlit version and configuration. This makes st.dataframe suitable for datasets where users may want to explore or analyze the data directly in the dashboard.

In contrast, st.table provides a simple, static snapshot of the data. There are no interactive features—users cannot sort, scroll, or filter. The table appears just as you render it, which is useful when you want to display summary information or small tables where interactivity is unnecessary.

Choosing between st.dataframe and st.table depends on your use case. For interactive exploration and larger datasets, prefer st.dataframe. For concise, static presentations, use st.table.

question mark

When should you use st.dataframe versus st.table in a Streamlit dashboard?

Select all correct answers

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 5
some-alt