Summary
I want to update a line chart by adding rows. This works as long as I don’t specify x & y in st.line_chart(…). But as soon as I add those parameters I get the following error:
Unsupported operation. The data passed into `add_rows()` must have the same data signature as the original data.
In this case, `add_rows()` received `["int64","unicode","float64"]` but was expecting `["int64","float64"]`.
Steps to reproduce
Code snippet:
import streamlit as st
import pandas as pd
import time
df = pd.DataFrame({"steps":[0,1,2,3],"values": [4,2,1.4,0.9]})
my_chart = st.line_chart(df, x="steps", y="values")
df_new = pd.DataFrame({"steps":[4,5,6],"values": [0.5,0.3,0.5]})
time.sleep(3)
my_chart.add_rows(df_new)
Expected behavior:
The chart should be updated using this data:
steps values
0 4.0
1 2.0
2 1.4
3 0.9
4 0.5
5 0.3
6 0.5
Actual behavior:
When I run my_chart = st.line_chart(df)
then the error doesn’t pop up but the chart is not what I want. I want to use ‘steps’ as x-values for my graph and ‘values’ as y-values.
Debug info
- Streamlit version: 1.16.0
- Python version: 3.10.8
- Using Conda
- OS version: MacOS 12.5.1
- Browser version: Chrome - Version 108.0.5359.124 (Official Build) (x86_64)