Spaces:
Sleeping
Sleeping
Update pages/5_Structured_data.py
Browse files- pages/5_Structured_data.py +39 -19
pages/5_Structured_data.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
import numpy as np
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
import random
|
| 6 |
import requests
|
|
|
|
| 7 |
st.markdown("""
|
| 8 |
<style>
|
| 9 |
/* Set a soft background color */
|
|
@@ -43,7 +44,7 @@ st.markdown("""
|
|
| 43 |
p {
|
| 44 |
font-family: 'Georgia', serif;
|
| 45 |
line-height: 1.8;
|
| 46 |
-
color: #FFFFFF;
|
| 47 |
margin-bottom: 20px;
|
| 48 |
}
|
| 49 |
/* List styling with checkmark bullets */
|
|
@@ -55,7 +56,7 @@ st.markdown("""
|
|
| 55 |
font-family: 'Georgia', serif;
|
| 56 |
font-size: 1.1em;
|
| 57 |
margin-bottom: 10px;
|
| 58 |
-
color: #FFFFF0;
|
| 59 |
}
|
| 60 |
.icon-bullet li::before {
|
| 61 |
content: "βοΈ";
|
|
@@ -71,30 +72,49 @@ st.markdown("""
|
|
| 71 |
.sidebar h2 {
|
| 72 |
color: #495057;
|
| 73 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
</style>
|
| 75 |
""", unsafe_allow_html=True)
|
| 76 |
-
|
| 77 |
-
st.
|
| 78 |
-
st.
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
'''
|
| 82 |
-
st.code(rcode,language="python")
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
| 85 |
df = pd.read_excel(r"/Users/rajbunny/Downloads/Book3.xlsx", sheet_name=[0, 1, 2])
|
| 86 |
'''
|
| 87 |
-
st.code(mcode,language="python")
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
| 90 |
with pd.ExcelWriter(r'/Users/rajbunny/Downloads/untitled_folder.xlsx', mode="x") as f2:
|
| 91 |
df[0].to_excel(f2, sheet_name='student_info')
|
| 92 |
df[1].to_excel(f2, sheet_name='sem1')
|
| 93 |
df[2].to_excel(f2, sheet_name='sem2')
|
| 94 |
'''
|
| 95 |
-
st.code(scode,language="python")
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
notebook_url = "http://localhost:8888/notebooks/exel.ipynb"
|
| 100 |
-
st.markdown(f"[Click here to go to the Jupyter notebook]
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
import random
|
| 6 |
import requests
|
| 7 |
+
|
| 8 |
st.markdown("""
|
| 9 |
<style>
|
| 10 |
/* Set a soft background color */
|
|
|
|
| 44 |
p {
|
| 45 |
font-family: 'Georgia', serif;
|
| 46 |
line-height: 1.8;
|
| 47 |
+
color: #FFFFFF;
|
| 48 |
margin-bottom: 20px;
|
| 49 |
}
|
| 50 |
/* List styling with checkmark bullets */
|
|
|
|
| 56 |
font-family: 'Georgia', serif;
|
| 57 |
font-size: 1.1em;
|
| 58 |
margin-bottom: 10px;
|
| 59 |
+
color: #FFFFF0;
|
| 60 |
}
|
| 61 |
.icon-bullet li::before {
|
| 62 |
content: "βοΈ";
|
|
|
|
| 72 |
.sidebar h2 {
|
| 73 |
color: #495057;
|
| 74 |
}
|
| 75 |
+
/* Custom button style */
|
| 76 |
+
.streamlit-button {
|
| 77 |
+
background-color: #00FFFF;
|
| 78 |
+
color: #000000;
|
| 79 |
+
font-weight: bold;
|
| 80 |
+
}
|
| 81 |
</style>
|
| 82 |
""", unsafe_allow_html=True)
|
| 83 |
+
|
| 84 |
+
st.title("π Handling Excel Files π")
|
| 85 |
+
st.markdown("Excel is a tool for organizing and analyzing data in a structured table format using rows and columns. It's commonly used for storing and analyzing datasets. π", unsafe_allow_html=True)
|
| 86 |
+
|
| 87 |
+
# Code for reading Excel file
|
| 88 |
+
st.subheader("π How to read an Excel file?")
|
| 89 |
+
rcode = '''
|
| 90 |
+
# Reading an Excel file with a single sheet
|
| 91 |
+
df = pd.read_excel(r"/Users/rajbunny/Downloads/FSI-2023-DOWNLOAD.xlsx")
|
| 92 |
'''
|
| 93 |
+
st.code(rcode, language="python")
|
| 94 |
+
|
| 95 |
+
# Code for reading Excel file with multiple sheets
|
| 96 |
+
st.subheader("π How to read an Excel file with multiple sheets?")
|
| 97 |
+
mcode = '''
|
| 98 |
+
# Reading multiple sheets from an Excel file
|
| 99 |
df = pd.read_excel(r"/Users/rajbunny/Downloads/Book3.xlsx", sheet_name=[0, 1, 2])
|
| 100 |
'''
|
| 101 |
+
st.code(mcode, language="python")
|
| 102 |
+
|
| 103 |
+
# Code for saving DataFrame back to Excel
|
| 104 |
+
st.subheader("πΎ How to save DataFrame back to Excel?")
|
| 105 |
+
scode = '''
|
| 106 |
+
# Saving DataFrame to a new Excel file
|
| 107 |
with pd.ExcelWriter(r'/Users/rajbunny/Downloads/untitled_folder.xlsx', mode="x") as f2:
|
| 108 |
df[0].to_excel(f2, sheet_name='student_info')
|
| 109 |
df[1].to_excel(f2, sheet_name='sem1')
|
| 110 |
df[2].to_excel(f2, sheet_name='sem2')
|
| 111 |
'''
|
| 112 |
+
st.code(scode, language="python")
|
| 113 |
+
|
| 114 |
+
# Interactive button for Jupyter notebook link
|
| 115 |
+
st.subheader("π To view the coding part of the Jupyter notebook:")
|
| 116 |
+
|
| 117 |
+
if st.button("π Open Jupyter Notebook"):
|
| 118 |
notebook_url = "http://localhost:8888/notebooks/exel.ipynb"
|
| 119 |
+
st.markdown(f"[Click here to go to the Jupyter notebook]({notebook_url})", unsafe_allow_html=True)
|
| 120 |
+
|