This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
st.title('GDELT Actor Explorer') | |
if len(codes) > 0: | |
st.subheader('Actor types selected') | |
st.markdown(get_actor_code_descriptions(codes)) | |
# Compute the filter | |
filter = create_filter(codes, date_min, date_max) | |
# Compute all relevant data needed for visualisation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Choose actor codes | |
codes = st.sidebar.multiselect( | |
label='Select Actor Types', | |
default='EDU', | |
options=list(actor_codes.keys()), | |
help='Select one ore more Actor Type codes.') | |
# Specify date range | |
date_range = st.sidebar.slider( | |
label='Date Range', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute_data(filter, binner_resolution, progress_function=None): | |
# Filter the data | |
dff = df.filter(filter) | |
## Aggregators for the global (worldwide trackers) | |
aggs_global = {'mean_avg_tone': vaex.agg.mean(dff.AvgTone), | |
'std_avg_tone': vaex.agg.std(dff.AvgTone), | |
'mean_goldstein_scale': vaex.agg.mean(dff.GoldsteinScale), | |
'std_goldstein_scale': vaex.agg.std(dff.GoldsteinScale)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_filter(codes, date_min, date_max): | |
filter = (df.Actor1Type1Code.isin(codes) | | |
df.Actor1Type2Code.isin(codes) | | |
df.Actor1Type3Code.isin(codes) | | |
df.Actor2Type1Code.isin(codes) | | |
df.Actor2Type2Code.isin(codes) | | |
df.Actor2Type3Code.isin(codes)) | |
if date_min is not None: | |
filter = filter & (df.Date >= date_min) | |
if date_max is not None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
from operator import itemgetter | |
import datetime | |
import streamlit as st | |
import numpy as np | |
import plotly.express as px | |
import plotly.graph_objects as go | |
import vaex | |
from wordcloud import WordCloud | |
from actor_codes import actor_codes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import numpy as np | |
import matplotlib.pyplot as plt | |
st.subheader('Hallo wave!') # Let's create a title for our app | |
# These are two parameters we want to modify interactively, by means of a slider | |
phi = st.slider(label='phase', min_value=-2*np.pi, max_value=2*np.pi, value=0.0, step=0.1) | |
freq = st.slider(label='frequency', min_value=0.1, max_value=5.0, value=1.0, step=0.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
app.run_server(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import dash | |
from dash.dependencies import Input, Output, State | |
import dash_core_components as dcc | |
import dash_html_components as html | |
import plotly.graph_objs as go | |
import plotly.express as px | |
from flask_caching import Cache | |
import numpy as np | |
import vaex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_figure_empty(): | |
layout = go.Layout(plot_bgcolor='white', width=10, height=10, | |
xaxis=go.layout.XAxis(visible=False), | |
yaxis=go.layout.YAxis(visible=False)) | |
return go.FigureWidget(layout=layout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.callback([Output('trip_summary_amount_figure', 'figure'), | |
Output('trip_summary_duration_figure', 'figure'), | |
Output('trip_summary_md', 'children')], | |
[Input('days', 'value'), | |
Input('hours', 'value'), | |
Input('trip_start', 'data'), | |
Input('trip_end', 'data')] | |
) | |
def trip_details_summary(days, hours, trip_start, trip_end): | |
if trip_start is None or trip_end is None: |
NewerOlder