Created
May 15, 2024 16:35
-
-
Save dharmatech/14b9ff5912f98cc1b303f2fd12fc4136 to your computer and use it in GitHub Desktop.
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 pandas as pd | |
import treasury_gov_pandas.datasets.mts.mts_table_4.load | |
import streamlit as st | |
import plotly.express as px | |
import numpy as np | |
df = treasury_gov_pandas.datasets.mts.mts_table_4.load.load() | |
# convert null values to 0 in the column 'current_month_net_rcpt_amt' | |
# df['current_month_net_rcpt_amt'] = df['current_month_net_rcpt_amt'].fillna(0) | |
df['record_date'] = pd.to_datetime(df['record_date']) | |
df['current_month_net_rcpt_amt'] = pd.to_numeric(df['current_month_net_rcpt_amt'], errors='coerce') | |
df['current_month_gross_rcpt_amt'] = pd.to_numeric(df['current_month_gross_rcpt_amt'], errors='coerce') | |
# df.drop(columns=['record_calendar_day', 'record_calendar_month']) | |
# df.iloc[-1] | |
colunns_to_exclude = [ | |
'parent_id', | |
'classification_id', | |
"table_nbr", | |
"src_line_nbr", | |
"print_order_nbr", | |
"line_code_nbr", | |
"data_type_cd", | |
"record_type_cd", | |
"sequence_level_nbr", | |
"sequence_number_cd", | |
"record_fiscal_year", | |
"record_fiscal_quarter", | |
"record_calendar_year", | |
"record_calendar_quarter", | |
"record_calendar_month", | |
"record_calendar_day" | |
] | |
desc = 'Total -- Individual Income Taxes' | |
# df.query('classification_desc == @desc').drop(columns=colunns_to_exclude + ['classification_desc']).iloc[-1] | |
# record_date 2024-04-30 | |
# current_month_gross_rcpt_amt 556507119650.53 | |
# current_month_refund_amt 74580543634.82 | |
# current_month_net_rcpt_amt 481926576015.71 | |
# current_fytd_gross_rcpt_amt 1812511378855.04 | |
# current_fytd_refund_amt 241282769556.44 | |
# current_fytd_net_rcpt_amt 1571228609298.60 | |
# prior_fytd_gross_rcpt_amt 1676082840455.62 | |
# prior_fytd_refund_amt 265760582660.48 | |
# prior_fytd_net_rcpt_amt 1410322257795.14 | |
tmp = df.query('classification_desc == "Total -- Individual Income Taxes"')[['record_date', 'current_fytd_net_rcpt_amt', 'prior_fytd_net_rcpt_amt']] | |
fig = px.line(tmp, x='record_date', y=['current_fytd_net_rcpt_amt', 'prior_fytd_net_rcpt_amt'], title='Total -- Individual Income Taxes') | |
st.plotly_chart(fig, use_container_width=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment