Update pages/Introduction.py
Browse files- pages/Introduction.py +14 -27
pages/Introduction.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
|
| 4 |
# Set up the app's title and description
|
| 5 |
st.title("Hotel Data Analysis App")
|
|
@@ -18,31 +19,17 @@ The dataset includes hotel-related information such as price, ratings, discounts
|
|
| 18 |
|
| 19 |
# File upload section
|
| 20 |
st.markdown("## Upload Your Dataset")
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
st.dataframe(df.head())
|
| 33 |
-
|
| 34 |
-
# Convert the dataset to CSV for download
|
| 35 |
-
csv = df.to_csv(index=False).encode('utf-8')
|
| 36 |
-
|
| 37 |
-
# Add a download button for the processed dataset
|
| 38 |
-
st.markdown("### Download Processed Dataset")
|
| 39 |
-
st.download_button(
|
| 40 |
-
label="Download Sample Dataset",
|
| 41 |
-
data=csv,
|
| 42 |
-
file_name="hotel_data.csv",
|
| 43 |
-
mime="text/csv"
|
| 44 |
-
)
|
| 45 |
-
except Exception as e:
|
| 46 |
-
st.error(f"An error occurred while processing the file: {e}")
|
| 47 |
else:
|
| 48 |
-
st.
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
# Set up the app's title and description
|
| 6 |
st.title("Hotel Data Analysis App")
|
|
|
|
| 19 |
|
| 20 |
# File upload section
|
| 21 |
st.markdown("## Upload Your Dataset")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# Define default file path
|
| 25 |
+
default_path = r"C:\Users\YourUsername\Downloads\agoda_data.csv"
|
| 26 |
+
|
| 27 |
+
# Input field to allow manual file path entry
|
| 28 |
+
file_path = st.text_input("Enter the file path to your dataset:", value=default_path)
|
| 29 |
+
|
| 30 |
+
if os.path.exists(file_path):
|
| 31 |
+
df = pd.read_csv(file_path)
|
| 32 |
+
st.dataframe(df.head())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
else:
|
| 34 |
+
st.error(f"File not found at {file_path}. Please check the path.")
|
| 35 |
+
|