/
app_p1.py
37 lines (27 loc) · 1018 Bytes
/
app_p1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Import the required Libraries
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
# Add a title and intro text
st.title('Earthquake Data Explorer')
st.text('This is a web app to allow exploration of Earthquake Data')
# Create file uploader object
upload_file = st.file_uploader('Upload a file containing earthquake data')
# Check to see if a file has been uploaded
if upload_file is not None:
# If it has then do the following:
# Read the file to a dataframe using pandas
df = pd.read_csv(upload_file)
# Create a section for the dataframe statistics
st.header('Statistics of Dataframe')
st.write(df.describe())
# Create a section for the dataframe header
st.header('Header of Dataframe')
st.write(df.head())
# Create a section for matplotlib figure
st.header('Plot of Data')
fig, ax = plt.subplots(1,1)
ax.scatter(x=df['Depth'], y=df['Magnitude'])
ax.set_xlabel('Depth')
ax.set_ylabel('Magnitude')
st.pyplot(fig)