I wanted to display a simple table and rename the columns.
It works, it displays but I get an error in the log.
requirements.txt:
streamlit==1.36.0
Error:
2024-07-15 16:21:19.632 Uncaught app exception
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 589, in _run_script
exec(code, module.__dict__)
File "/app/pages/List_test.py", line 21, in <module>
st.table(df2)
File "/usr/local/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 408, in wrapped_func
result = non_optional_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/streamlit/elements/arrow.py", line 628, in table
marshall(proto, data, default_uuid)
File "/usr/local/lib/python3.12/site-packages/streamlit/elements/arrow.py", line 721, in marshall
df = type_util.convert_anything_to_df(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/streamlit/type_util.py", line 669, in convert_anything_to_df
return cast(pd.DataFrame, data.to_pandas())
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/streamlit/delta_generator.py", line 345, in wrapper
raise StreamlitAPIException(message)
streamlit.errors.StreamlitAPIException: `to_pandas()` is not a valid Streamlit command.
.
Code:
import streamlit as st
column_configuration = {
"0": st.column_config.TextColumn(
"Col 0", help="Test name", max_chars=200, width="medium"
),
"1": st.column_config.TextColumn(
"Col 1", help="repo", max_chars=200, width="medium"
)
}
list = [('col 0.1', 'col 1.1'),
('col 0.2', 'col 1.2'),
('col 0.3', 'col 1.3')]
df2 = st.dataframe(list,
column_config=column_configuration
)
st.table(df2)