-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Summary
Clicking the column/index headers once sorts the st.dataframe by ascending, clicking them once again sorts the dataframe by descending, but further clicks do nothing more.
Steps to reproduce
Following the Uber example from the Streamlit docs:
import streamlit as st
import pandas as pd
DATE_COLUMN = 'date/time'
DATA_URL = 'https://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz'
@st.cache
def load_data(nrows: int) -> pd.DataFrame:
data = pd.read_csv(DATA_URL, nrows=nrows)
data.rename(lambda x: str(x).lower(), axis='columns', inplace=True)
data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
return data
data_load_state = st.markdown("Loading data...")
data = load_data(20)
data_load_state.markdown("Done loading data using `st.cache`!")
st.write(data)
- Run the streamlit app above.
- Click on any of the column headers (e.g. date/time) in the dataframe, >2 times consecutively.
Expected behavior:
Clicking on the column or index headers toggles the column sorting between asc and desc.
Currently it seems the only way to do so would be to click a different column header (to sort by that col), so that the sorting order on the original column is reset.
Actual behavior:
The dataframe sorting stops at "desc", and further clicks on the headers won't toggle the sorting any further.
Is this a regression?
Unsure.
Debug info
- Streamlit version: 0.70.0
- Python version: 3.8.2
- Pyenv
- OS version: Mac OS Catalina 10.15.7
- Browser version: Firefox 82.0.2 (64 bit)
Additional information
Originally discussed here https://discuss.streamlit.io/t/sorting-dataframe-does-not-toggle-between-asc-and-desc/6805
If this is not a bug, consider this a feature request? :) Thanks.