-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathapp.py
More file actions
88 lines (46 loc) · 1.24 KB
/
app.py
File metadata and controls
88 lines (46 loc) · 1.24 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
#!/usr/bin/env python
# coding: utf-8
# In[3]:
import pandas as pd # for dataframes
import numpy as np # for NaN
import matplotlib.pyplot as plt # for visualization
import seaborn as sns
import streamlit as st
# In[27]:
'''
# Creating Web Apps with JN and Streamlit
## Christian F. Jung
christianfjung.com
**About this Project**
This project uses live poll data from 538 so the website will be update constantly!
'''
# In[4]:
df_online= pd.read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/media-mentions-2020/online_weekly.csv")
df_online.head()
# # Most Online Attention to this Date
#
# In[6]:
dfO= df_online[['name','matched_stories']]
dfO= dfO.groupby("name")["matched_stories"].sum()
dfO = pd.DataFrame(dfO)
dfToShow= dfO.sort_values("matched_stories", ascending=False)
dfToShow.head()
# In[23]:
st.bar_chart(dfToShow)
# In[ ]:
# # What does the script do?
#
# Converts NB to .py
# `jupyter nbconvert --to script YOURNAME.ipynb`
#
#
#
#
#
# Runs the local streamlit app
# `streamlit run app.py`
# In[ ]:
# ## Try it on your own with cable data:
# `df_cable= pd.read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/media-mentions-2020/cable_weekly.csv")`
#
# In[ ]: