Spaces:
Runtime error
Runtime error
File size: 3,553 Bytes
cfd4139 dd4d9a4 cfd4139 dd4d9a4 4328fda b816a05 cfd4139 2d5e6ee cfd4139 2d5e6ee cfd4139 2d5e6ee b816a05 2d5e6ee b816a05 2d5e6ee b816a05 2d5e6ee cfd4139 2d5e6ee cfd4139 2d5e6ee b816a05 010fa37 b816a05 cfd4139 |
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 99 100 101 102 103 104 |
# -*- coding: utf-8 -*-
import streamlit as st
import plotly.express as px
from data_processing import load_data, process_data, get_monetary_dataframe, get_themes_per_year
def _max_width_():
max_width_str = f"max-width: 1500px;"
st.markdown(
f"""
<style>
.reportview-container .main .block-container{{
{max_width_str}
}}
</style>
""",
unsafe_allow_html=True,
)
# force screen width
_max_width_()
st.title("Data Analysis π π")
st.write("by [Teolex](https://www.theolex.io/)")
# load and process data
data = load_data()
decisions, organizations, authorities = process_data(data)
st.sidebar.title("Parameters")
authorities_country = st.sidebar.selectbox('Authority country', authorities.country.unique())
select_auth = authorities[authorities.country == authorities_country].name.sort_values()
authority = st.sidebar.selectbox('Authority', ['All', *select_auth])
min_year, max_year = st.sidebar.slider('Decisions year', min_value=2001, max_value=2021, value=(2010, 2021))
# apply filters
authority_filter = True
if authority != 'All':
authority_filter = decisions.authorities_name.apply(lambda a: authority in a)
else:
authority_filter = decisions.authorities_name.apply(lambda a: bool(set(select_auth) & set(a)))
year_filter = (decisions.year >= min_year) & (decisions.year <= max_year)
decision_scope = decisions[authority_filter & year_filter]
# explore monetary sanctions
monetary_decision = get_monetary_dataframe(decision_scope)
##
# Plot Graphs
##
st.subheader("The organizations' sectors targeted by the sanctions: ")
st.markdown("The graph shows the cumulated monetary sanction for the current filters")
fig = px.treemap(monetary_decision,
path=['org_company_type'],
color='org_revenues',
color_continuous_scale='RdBu',
template="simple_white",
values='monetary_sanction',
width=1000, height=600)
st.plotly_chart(fig)
st.subheader("The organizations' regions targeted by the sanctions: ")
st.markdown("The graph shows the cumulated monetary sanction for the current filters")
fig = px.treemap(monetary_decision[~monetary_decision.org_continent.isnull()],
path=['org_continent', 'org_country'],
color_continuous_scale='RdBu',
template="simple_white",
values='monetary_sanction',
width=1000, height=600)
st.plotly_chart(fig)
st.subheader("Revenues vs monetary sanctions representation ")
st.markdown("The graph shows the cumulated monetary sanction for the current filters")
fig = px.scatter(monetary_decision,
x="org_revenues",
y="monetary_sanction",
log_x=True,
log_y=True,
template="simple_white",
color="same_country",
color_continuous_scale='RdBu',
hover_name="org_name",
width=1000, height=600)
st.plotly_chart(fig)
st.subheader("Sum of monetary sanctions over time ")
st.markdown("The graph shows the cumulated monetary sanction per year for each violation theme")
chart_data = get_themes_per_year(monetary_decision)
fig = px.area(chart_data, x="year",
y="monetary_sanction",
color="violation_theme",
template="simple_white",
# groupnorm="fraction",
line_group="violation_theme",
width=1000, height=600)
st.plotly_chart(fig)
|