Create image_df_display.py
Browse files- image_df_display.py +42 -0
image_df_display.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Sample DataFrame
|
| 5 |
+
df1 = pd.DataFrame({
|
| 6 |
+
'Name': ['John', 'Alice', 'Bob'],
|
| 7 |
+
'Age': [30, 25, 35]
|
| 8 |
+
})
|
| 9 |
+
|
| 10 |
+
# Sample DataFrame
|
| 11 |
+
df2 = pd.DataFrame({
|
| 12 |
+
'City': ['New York', 'Los Angeles', 'Chicago'],
|
| 13 |
+
'Population': [8398748, 3990456, 2705994]
|
| 14 |
+
})
|
| 15 |
+
|
| 16 |
+
# Sample images
|
| 17 |
+
image_urls = {
|
| 18 |
+
'Image 1': "https://via.placeholder.com/150",
|
| 19 |
+
'Image 2': "https://via.placeholder.com/150",
|
| 20 |
+
'Image 3': "https://via.placeholder.com/150"
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
# Display the app title
|
| 24 |
+
st.title('Image and DataFrame Display')
|
| 25 |
+
|
| 26 |
+
# Display the image selection dropdown on the left half
|
| 27 |
+
st.sidebar.title('Select Image')
|
| 28 |
+
selected_image = st.sidebar.selectbox('Select Image:', options=list(image_urls.keys()))
|
| 29 |
+
|
| 30 |
+
# Display the selected image on the left half
|
| 31 |
+
st.sidebar.image(image_urls[selected_image], caption=selected_image)
|
| 32 |
+
|
| 33 |
+
# Display the DataFrame selection dropdown on the right half
|
| 34 |
+
st.sidebar.title('Select DataFrame')
|
| 35 |
+
selected_df = st.sidebar.selectbox('Select DataFrame:', options=['DataFrame 1', 'DataFrame 2'])
|
| 36 |
+
|
| 37 |
+
# Display the selected DataFrame on the right half
|
| 38 |
+
st.write('## Selected DataFrame')
|
| 39 |
+
if selected_df == 'DataFrame 1':
|
| 40 |
+
st.write(df1)
|
| 41 |
+
elif selected_df == 'DataFrame 2':
|
| 42 |
+
st.write(df2)
|