Summary
In my app I create a pandas pivot-table in a human-readable grid. Below the columns headers I have included a row of descriptive text while the remaining row data are all numeric floats. After converting from streamlit 1.17.0 to 1.20.0, I am getting small yellow triangle exclamation points and a warning saying: “The value cannot be interpreted as a number.” How can I suppress or disable these warnings? The pivot table will always have non-numeric text.
Steps to reproduce
Code snippet:
import streamlit as st
import pandas as pd
d = pd.DataFrame({
'Mix number':[1,2,3],
'Mix Name':['Control','Test1','Test2'],
'Ingredient number':[4,5,6],
'Ingredient name':['A','B','C'],
'Level':[33,33,34]
})
pivot_table = pd.pivot_table(
data=d,
values='Level',
index=['Ingredient number','Ingredient name'],
columns=['Mix number','Mix Name']
)
st.dataframe(pivot_table)
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
Display data without data warnings.
Actual behavior:
Shows little yellow triangles with data warning.
Debug info
- Streamlit version: 1.20.0
- Python version: 3.10
- Using Conda? PipEnv? PyEnv? Pex?
- OS version: Windows 10
- Browser version: Chrome
I’m having a similar issue so would love to hear more.
I’ve tried converting the numeric column header “Mix number” into string but still same issue.
Bump…still having this issue. Any ideas? I haven’t been able to find any documentation of this or similar issues anywhere.
Perhaps not the most elegant, but here are a couple options:
import streamlit as st
import pandas as pd
d = pd.DataFrame({
'Mix number':[1,2,3],
'Mix Name':['Control','Test1','Test2'],
'Ingredient number':[4,5,6],
'Ingredient name':['A','B','C'],
'Level':[33,33,34]
})
pivot_table = pd.pivot_table(
data=d,
values='Level',
index=['Ingredient number','Ingredient name'],
columns=['Mix number','Mix Name']
)
pivot1 = pivot_table.fillna('')
pivot2 = pivot_table.copy()
for col in pivot_table.columns:
pivot2[col] = pivot2[col].astype(str)
st.dataframe(pivot_table)
st.dataframe(pivot1)
st.dataframe(pivot2)
I suspect this is related to some underlying work on the data editor. Ping @lukasmasuch
Unfortunately, we do not officially support dataframes with multiple header rows at the moment
There are some workarounds, as shown by @mathcatsand by manually converting to string. We are tracking this issue here on Github: Enable `st.dataframe` to handle dataframes with hierarchical headers · Issue #6319 · streamlit/streamlit · GitHub You can help to prioritize this issue by upvoting it on Github.