Sorting dataframe does not toggle between asc and desc

Hi there, I am currently following the tutorial from the Streamlit docs on Uber pickups, and have a question regarding the table shown using st.dataframe.
Clicking the column/index headers once sorts the dataframe by ascending, clicking them once again sorts the dataframe by descending, but further clicks do nothing more.

Would it be possible to allow for toggling between ascending and descending?
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.

Thanks.

A simple code snippet:

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)

Hi @thatlittleboy, welcome to the Streamlit community!

That is a pretty strange behavior, which I suspect is a bug. Would you be able to open an issue on GitHub so that we can research it further?

Best,
Randy

Thank you, I’ve opened an issue here.

1 Like

@thatlittleboy, I’m working on it right now. Should be fixed soon.

PR is out. The fix will be included in the next version.
Thanks again for filing the issue :wave:

awesome, :clap: thanks!

1 Like

You’re always welcome!

Hi @kantuni
Has the issue been fixed now?? I am also observing the same issue