Hi All, I have issues in accessing the user inputs.
col1, col2, col3 = st.columns(3)
name = col1.text_input("Your Name : ")
email = col2.text_input("Your Email ID : ")
phone = col3.text_input("Your Phone Number : ")
sub_base = pd.DataFrame(columns = [‘Name’, ‘Category’, ‘Date’, ‘E-mail’, ‘Phone’, ‘Domicile State’])
sub_base[‘Name’] = name
The variable ‘name’ has no data flowing in. I haven’t created any sessions per se. can you please let me know how user inputs could be accessed later ?
Hi @PraneethPonnekanti ,
Try this code snippet below, hope it helps !
import streamlit as st
import pandas as pd
col1, col2, col3 = st.columns(3)
name = col1.text_input("Your Name : ")
email = col2.text_input("Your Email ID : ")
phone = col3.text_input("Your Phone Number : ")
sub_base = pd.DataFrame(columns = ["Name", "Category", "Date", "E-mail", "Phone", "Domicile State"])
# Create button to display
btn = st.button("Show names")
# You can form a dict beforehand, altenatively
#data = {"Name": name , "Category":{},"E-mail":email,"Phone":phone}
# If button pressed then display the inputs
if btn:
#sub_base = sub_base.append(data, ignore_index=True)
sub_base = sub_base.append(
{"Name": name,
"E-mail":email,
"Phone":phone},ignore_index=True)
st.write(sub_base)
Best,
Avra
system
Closed
October 14, 2022, 9:13am
3
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.