I would like to change from the vertical input to column input using streamlit also, columns have to be dynamic
Question:
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)
st.subheader('Enter the T value into row for multiplication')
for i in range(tb):
value = st.number_input(f'row{i}:', min_value=0, max_value=10, step=1)
t.append(value)
t = np.array(t)
t = np.tile(t, (p.shape[1], 1)).T
p_mod = np.multiply(p, t)
st.header('Output Data')
st.dataframe(p_mod)
Suppose If I run the above code I would get the number input in vertical order but I would like to have in horizontal order
Answers:
I think what you are looking for is st.columns!
Maybe try
c = st.columns(tb)
for i in range(tb):
value = c[i].number_input(f'row{i}:', min_value=0, max_value=10, step=1)
t.append(value)
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)
st.subheader('Enter the T value into row for multiplication')
for i in range(tb):
value = st.number_input(f'row{i}:', min_value=0, max_value=10, step=1)
t.append(value)
t = np.array(t)
t = np.tile(t, (p.shape[1], 1)).T
p_mod = np.multiply(p, t)
st.header('Output Data')
st.dataframe(p_mod)
Suppose If I run the above code I would get the number input in vertical order but I would like to have in horizontal order
I think what you are looking for is st.columns!
Maybe try
c = st.columns(tb)
for i in range(tb):
value = c[i].number_input(f'row{i}:', min_value=0, max_value=10, step=1)
t.append(value)