Summary
Share a clear and concise description of the issue. Aim for 2-3 sentences.
Steps to reproduce
Code snippet:
import numpy as np
import streamlit as st
st.header('Input Data')
p = np.array([[4,3,6,2],[1,4,3,5],[2,5,2,3],[5,2,4,1],[3,6,1,4]])
st.dataframe(p)
t = [ ]
tb = len(p)
for i in range(0, tb):
ele = [int(input(f'Enter the value into {i} row for multiplication:'))]
t.append(ele)
n = len(p)
l = list(map(int,input(f"\nEnter the {n} numbers row wise to repeat the matrix: ").strip().split()))[:n]
pt = np.multiply(p,t)
m = max(l)
idx = np.tile(np.arange(len(pt)), m)
idx = idx[np.repeat(np.arange(m), len(l)) < np.tile(l, m)]
p = pt[idx]
st.header('Output Data')
st.write(p)
I want to implement the above code. Suppose if I run the above program, the input would ask in the terminal shown in the below figure
I am getting the output like this but I want to enter the the input values within the streamlit webapp
Expected behavior:
I tried to use the streamlit slider for the number input but it shows the error
Code snippet:
import numpy as np
import streamlit as st
st.header('Input Data')
p = np.array([[4,3,6,2],[1,4,3,5],[2,5,2,3],[5,2,4,1],[3,6,1,4]])
st.dataframe(p)
t = [ ]
tb = len(p)
t = [st.sidebar.number_input(f'Enter the value into {i} row for multiplication:', min_value = 0, max_value = 10, step= 1) for i in range(0, tb)]
st.write(t)
n = len(p)
l = [st.sidebar.number_input(f"\nEnter the {n} numbers row wise to repeat the matrix: ") for i in range(0, tb)]
pt = np.multiply(p,t)
m = max(l)
idx = np.tile(np.arange(len(pt)), m)
idx = idx[np.repeat(np.arange(m), len(l)) < np.tile(l, m)]
p = pt[idx]
st.header('Output Data')
st.write(p)
Explain what you expect to happen when you run the code above.
If I run the above program it shows the error and also I would like to get separate list for each value in the t input and vice-versa for l input I would like to get multiple input in same list
Actual behavior:
Debug info
- Streamlit version: 1.20.0
- Python version: 3.9
- Using Conda
- OS version:windows 10
- Browser version:
my desired output would look like this