import streamlit as st import plotly.express as px st.title("Hello World!") st.write("This is my first Streamlit app on Hugging Face Space") name = st.text_input("Enter your name : ") age = st.slider("Select your age : ", 0, 100, 25) if st.button("Submit"): st.write(f" Hello {name}, your are {age} years old!") # Example 1 : Text Input and Button st.title("Interactive App : User Input") # Text Input Feild name = st.text_input("Enter your name:") # Create Button if st.button("Greet"): st.write(f"Hello, {name}! Welcome to your first interactive Streamlit app.") # Example 2 : Dropdown Selection st.title("Dropdown Selection Example") # Dropdown menu options = ("Python", "JavaScript", "Java", "C++") chioce = st.selectbox("Choose a programming language :",options) st.write(f"You selected: {chioce}!") import streamlit as st st.title("Multi-Select Example") # Multi-select widget hobbies = st.multiselect("Select your hobbies:", ["Reading", "Traveling", "Cooking", "Gaming"]) st.write(f"Your selected hobbies are: {', '.join(hobbies)}") # CSV File Upload and Display # import streamlit as st # import pandas as pd # # import matplotlib.pyplot as plt # import plotly.express as px # st.title("CSV File Upload and Display") # # File uploader # uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"]) # if uploaded_file: # # Read the uploaded file # data = pd.read_csv(uploaded_file) # # Display the data preview # st.write("Data Preview:") # st.dataframe(data) # # Display data statistics # if uploaded_file: # st.write("Data Statistics:") # st.write(data.describe()) # # Display a line and Bar chart # if uploaded_file: # st.write("Line Chart Example:") # st.line_chart(data) # st.write("Bar Chart Example:") # st.bar_chart(data) # st.write("Custom Matplotlib Chart") # fig, ax = plt.subplots() # ax.plot(data.iloc[:, 0], data.iloc[:, 1]) # ax.set_title("Custom Line Plot") # st.pyplot(fig) # User selects x and y axes # x_axis = st.selectbox("Choose X-axis:", data.columns) # y_axis = st.selectbox("Choose Y-axis:", data.columns) # # Generate scatter plot # fig = px.scatter(data, x=x_axis, y=y_axis, title="Scatter Plot") # st.plotly_chart(fig) # Plotly Example # import streamlit as st # import pandas as pd # import plotly.express as px # st.title("CSV File Upload and Display") # # File uploader # uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"]) # if uploaded_file: # data = pd.read_csv(uploaded_file) # st.write("Just loaded Data:") # st.dataframe(data) # # User selects x and y axes # x_axis = st.selectbox("Choose X-axis:", data.columns) # y_axis = st.selectbox("Choose Y-axis:", data.columns) # # Generate scatter plot # fig = px.scatter(data, x=x_axis, y=y_axis, title="Scatter Plot") # st.plotly_chart(fig) import streamlit as st import pandas as pd import plotly.express as px st.title("Dashboard Example") # File uploader uploaded_file = st.file_uploader("Upload CSV for Dashboard", type=["csv"]) if uploaded_file: data = pd.read_csv(uploaded_file) st.sidebar.title("Dashboard Controls") # Sidebar controls column = st.sidebar.selectbox("Select column to analyze:", data.columns) chart_type = st.sidebar.selectbox("Choose chart type:", ["Bar", "Line", "Scatter"]) # Display summary st.write("Summary Statistics:") st.write(data.describe()) # Generate chart if chart_type == "Bar": st.bar_chart(data[column]) elif chart_type == "Line": st.line_chart(data[column]) else: fig = px.scatter(data, x=data.index, y=column) st.plotly_chart(fig)