Error "KeyError: 'id'" on st.dataframe where style.format is used - sensitive to dataframe size

Issue using st.dataframe with df.styles.format to format floats with 2 decimal places. See gist containing minimal case with 2 files at:

ERROR occurs at line containing this statement:
st.dataframe({‘ItemSubTotalAmount’: ‘{:.2f}’, ‘TaxAmount’: ‘{:.2f}’, ‘TotalAmount’: ‘{:.2f}’}))


streamlit run

streamlit run

The 1st example reads the CSV file from:

The 2nd example points read the CSV file from: (it has one more row):

1 Like


I also encounter this error attempting to display a large pandas styled dataframe.

With 58 columns (28 styled):

  • no error displaying 4519 rows or less
  • error displaying 4520 rows or more

I have created a bug and shared a workaround for this. See KeyError: 'id' when using st.dataframe with pandas.Styler object and number of cells is higher than pandas `styler.render.max_elements` option · Issue #5953 · streamlit/streamlit · GitHub

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.