Skip to content

Instantly share code, notes, and snippets.

View JovanVeljanoski's full-sized avatar

Jovan Veljanoski JovanVeljanoski

View GitHub Profile
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
# 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',
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)}
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:
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
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)
if __name__ == '__main__':
app.run_server(debug=True)
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
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)
@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: