-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.py
More file actions
106 lines (73 loc) · 3.16 KB
/
Copy pathdashboard.py
File metadata and controls
106 lines (73 loc) · 3.16 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- coding: utf-8 -*-
"""Hackathon_Plotly.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1lfZn9uS4OnJzh0FBJIIwCmHgdf2uQZOq
"""
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.express as px
import plotly.graph_objects as go
from shapely.geometry import Point
# pip install geopandas
import geopandas as gpd
from geopandas import GeoDataFrame
def show_data():
animal_data = pd.read_csv('clean_animal_data1.csv')
new_data = animal_data.drop_duplicates()
new_data = new_data.drop('Unnamed: 0', axis=1)
# new_data.describe()
st.subheader('Data')
st.dataframe(new_data)
st.subheader('Data Description')
st.dataframe(new_data.describe())
# Commented out IPython magic to ensure Python compatibility.
def show_plots(new_data):
st.subheader('Box Plot - Distance Travelled by each Species')
px.box(new_data, x='Species', y='distance_miles', points='all')
# Adding standard deviation and mean
box = go.Figure()
box.add_trace(go.Box(x=new_data.Species, y=new_data.distance_miles, marker_color='blue',
boxmean='sd'))
st.plotly_chart(box)
Dogs = new_data[new_data.Species=="Dog"].sort_values(by="distance_miles",ascending=False).head(20)
fig = go.Figure()
#Mean distance covered by the Species
st.subheader('Histogram - Average Distance Travelled by each Species')
fig = px.histogram(new_data, x="Species", y="distance_miles", histfunc="avg", nbins=8, text_auto=True, color ='Species')
st.plotly_chart(fig)
#Maximum distance covered by the Species
st.subheader('Histogram - Max Distance Travelled by each Species')
fig = px.histogram(new_data, x="Species", y="distance_miles", histfunc="max", nbins=8, text_auto=True, color="Species")
st.plotly_chart(fig)
fig = px.scatter_geo(new_data,lat='found_lat',lon='found_lng', hover_name="Species", color = "Species")
fig.update_layout(title = 'Animals Found', title_x=1)
fig.update_geos(
visible=False, resolution=110, scope="usa",
showcountries=True, countrycolor="Black",
showsubunits=True, subunitcolor="Blue"),
fig.add_scattergeo(
locations=new_data['justidiction_state'], ###codes for states,
locationmode='USA-states',
text=new_data['justidiction_state'],
mode='text')
st.subheader('Geoplot of Found Location')
st.plotly_chart(fig)
fig.update_layout(height=600, margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
fig = px.scatter_geo(new_data,lat='outcome_lat',lon='outcome_lng', hover_name="Species", color ='Species')
fig.update_layout(title = 'Animals Home', title_x=1)
fig.update_geos(
visible=False, resolution=110, scope="usa",
showcountries=True, countrycolor="Black",
showsubunits=True, subunitcolor="Blue")
fig.add_scattergeo(
locations=new_data['justidiction_state'], ###codes for states,
locationmode='USA-states',
text=new_data['justidiction_state'],
mode='text')
fig.update_layout(height=600, margin={"r":0,"t":0,"l":0,"b":0})
st.subheader('Geoplot of Outcome Location')
st.plotly_chart(fig)