Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,43 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
3 |
def load_data():
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
return df
|
12 |
|
13 |
|
14 |
-
def
|
15 |
df = load_data()
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
|
|
1 |
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
|
5 |
def load_data():
|
6 |
+
df = pd.DataFrame({
|
7 |
+
"tax_type": ["Income Tax", "Sales Tax", "Property Tax", "Corporate Tax", "Value Added Tax (VAT)",
|
8 |
+
"Income Tax", "Sales Tax", "Property Tax", "Corporate Tax", "Value Added Tax (VAT)"],
|
9 |
+
"compliance": [0.75, 0.82, 0.60, 0.70, 0.65,
|
10 |
+
0.79, 0.75, 0.66, 0.72, 0.68]
|
11 |
+
})
|
|
|
12 |
return df
|
13 |
|
14 |
|
15 |
+
def compliance_analysis(tax_type):
|
16 |
df = load_data()
|
17 |
|
18 |
+
compliance_rate = df[df["tax_type"] == tax_type]["compliance"].mean()
|
19 |
+
compliance_rate = round(compliance_rate * 100, 2)
|
20 |
+
|
21 |
+
df = df.groupby("tax_type").mean().reset_index()
|
22 |
+
df = df.sort_values("compliance", ascending=False)
|
23 |
|
24 |
+
fig = px.bar(df, x="compliance", y="tax_type", color="tax_type", orientation="h",
|
25 |
+
title="Average Compliance Rate for Tax Types",
|
26 |
+
labels={"compliance": "Compliance Rate (%)", "tax_type": "Tax Type"})
|
27 |
|
28 |
+
fig.update_xaxes(ticktext=[str(round(v * 100, 2)) + "%" for v in df["compliance"]],
|
29 |
+
tickvals=df["compliance"] * 100)
|
30 |
+
fig.update_layout(shapes=[
|
31 |
+
dict(type='line', x0=compliance_rate, x1=compliance_rate, y0=0, y1=1, yref='paper',
|
32 |
+
line=dict(color='red', dash='dash')),
|
33 |
+
dict(type='text', x=compliance_rate, y=1.1, yref='paper',
|
34 |
+
text=f"{tax_type} ({compliance_rate}%)", textangle=0, font=dict(color='red', size=12))
|
35 |
+
])
|
36 |
+
|
37 |
+
return fig
|
38 |
+
|
39 |
+
tax_types = ["Income Tax", "Sales Tax", "Property Tax", "Corporate Tax", "Value Added Tax (VAT)"]
|
40 |
+
selected_tax_type = st.selectbox("Select a tax type:", tax_types, index=0)
|
41 |
+
|
42 |
+
st.plotly_chart(compliance_analysis(selected_tax_type))
|
43 |
|