Spaces:
Runtime error
Runtime error
add theme violation
Browse files- .streamlit/config.toml +2 -0
- data_processing.py +5 -0
- stream_app.py +37 -6
.streamlit/config.toml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[theme]
|
| 2 |
+
base="dark"
|
data_processing.py
CHANGED
|
@@ -83,3 +83,8 @@ def get_monetary_dataframe(decision_scope):
|
|
| 83 |
monetary_decision['log10_monetary_sanction'] = monetary_decision.monetary_sanction.apply(np.log10)
|
| 84 |
monetary_decision['same_country'] = (monetary_decision.org_country == monetary_decision.authorities_country)
|
| 85 |
return monetary_decision
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
monetary_decision['log10_monetary_sanction'] = monetary_decision.monetary_sanction.apply(np.log10)
|
| 84 |
monetary_decision['same_country'] = (monetary_decision.org_country == monetary_decision.authorities_country)
|
| 85 |
return monetary_decision
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def get_themes_per_year(monetary_decision):
|
| 89 |
+
#return monetary_decision.groupby(['year', 'violation_theme'])['monetary_sanction'].sum().unstack().fillna(0)
|
| 90 |
+
return monetary_decision.groupby(['year', 'violation_theme'])['monetary_sanction'].sum().reset_index()
|
stream_app.py
CHANGED
|
@@ -3,7 +3,25 @@ import streamlit as st
|
|
| 3 |
|
| 4 |
import plotly.express as px
|
| 5 |
|
| 6 |
-
from data_processing import load_data, process_data, get_monetary_dataframe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
st.title("Data Analysis π π")
|
| 9 |
st.write("by [Teolex](https://www.theolex.io/)")
|
|
@@ -44,20 +62,21 @@ fig = px.treemap(monetary_decision,
|
|
| 44 |
color='org_revenues',
|
| 45 |
color_continuous_scale='RdBu',
|
| 46 |
template="simple_white",
|
| 47 |
-
values='monetary_sanction'
|
|
|
|
| 48 |
st.plotly_chart(fig)
|
| 49 |
|
| 50 |
st.subheader("The organizations' regions targeted by the sanctions: ")
|
| 51 |
st.markdown("The graph shows the cumulated monetary sanction for the current filters")
|
| 52 |
fig = px.treemap(monetary_decision[~monetary_decision.org_continent.isnull()],
|
| 53 |
-
path=['org_continent','org_country'],
|
| 54 |
color='org_revenues',
|
| 55 |
color_continuous_scale='RdBu',
|
| 56 |
template="simple_white",
|
| 57 |
-
values='monetary_sanction'
|
|
|
|
| 58 |
st.plotly_chart(fig)
|
| 59 |
|
| 60 |
-
|
| 61 |
st.subheader("Revenues vs monetary sanctions representation ")
|
| 62 |
st.markdown("The graph shows the cumulated monetary sanction for the current filters")
|
| 63 |
fig = px.scatter(monetary_decision,
|
|
@@ -68,5 +87,17 @@ fig = px.scatter(monetary_decision,
|
|
| 68 |
template="simple_white",
|
| 69 |
color="same_country",
|
| 70 |
color_continuous_scale='RdBu',
|
| 71 |
-
hover_name="org_name"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
st.plotly_chart(fig)
|
|
|
|
| 3 |
|
| 4 |
import plotly.express as px
|
| 5 |
|
| 6 |
+
from data_processing import load_data, process_data, get_monetary_dataframe, get_themes_per_year
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _max_width_():
|
| 10 |
+
max_width_str = f"max-width: 1500px;"
|
| 11 |
+
st.markdown(
|
| 12 |
+
f"""
|
| 13 |
+
<style>
|
| 14 |
+
.reportview-container .main .block-container{{
|
| 15 |
+
{max_width_str}
|
| 16 |
+
}}
|
| 17 |
+
</style>
|
| 18 |
+
""",
|
| 19 |
+
unsafe_allow_html=True,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# force screen width
|
| 24 |
+
_max_width_()
|
| 25 |
|
| 26 |
st.title("Data Analysis π π")
|
| 27 |
st.write("by [Teolex](https://www.theolex.io/)")
|
|
|
|
| 62 |
color='org_revenues',
|
| 63 |
color_continuous_scale='RdBu',
|
| 64 |
template="simple_white",
|
| 65 |
+
values='monetary_sanction',
|
| 66 |
+
width=1000, height=600)
|
| 67 |
st.plotly_chart(fig)
|
| 68 |
|
| 69 |
st.subheader("The organizations' regions targeted by the sanctions: ")
|
| 70 |
st.markdown("The graph shows the cumulated monetary sanction for the current filters")
|
| 71 |
fig = px.treemap(monetary_decision[~monetary_decision.org_continent.isnull()],
|
| 72 |
+
path=['org_continent', 'org_country'],
|
| 73 |
color='org_revenues',
|
| 74 |
color_continuous_scale='RdBu',
|
| 75 |
template="simple_white",
|
| 76 |
+
values='monetary_sanction',
|
| 77 |
+
width=1000, height=600)
|
| 78 |
st.plotly_chart(fig)
|
| 79 |
|
|
|
|
| 80 |
st.subheader("Revenues vs monetary sanctions representation ")
|
| 81 |
st.markdown("The graph shows the cumulated monetary sanction for the current filters")
|
| 82 |
fig = px.scatter(monetary_decision,
|
|
|
|
| 87 |
template="simple_white",
|
| 88 |
color="same_country",
|
| 89 |
color_continuous_scale='RdBu',
|
| 90 |
+
hover_name="org_name",
|
| 91 |
+
width=1000, height=600)
|
| 92 |
+
st.plotly_chart(fig)
|
| 93 |
+
|
| 94 |
+
st.subheader("Sum of monetary sanctions over time ")
|
| 95 |
+
st.markdown("The graph shows the cumulated monetary sanction per year for each violation theme")
|
| 96 |
+
chart_data = get_themes_per_year(monetary_decision)
|
| 97 |
+
fig = px.area(chart_data, x="year",
|
| 98 |
+
y="monetary_sanction",
|
| 99 |
+
color="violation_theme",
|
| 100 |
+
template="simple_white",
|
| 101 |
+
line_group = "violation_theme",
|
| 102 |
+
width=1000, height=600)
|
| 103 |
st.plotly_chart(fig)
|