Skip to content

Commit

Permalink
Merge pull request #19 from adarshkannada/AUG6
Browse files Browse the repository at this point in the history
show monthly charts
  • Loading branch information
adarshkannada authored Aug 6, 2023
2 parents 9d0a4e3 + 0b51e10 commit 746cd9a
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 66 deletions.
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ Utility code written for personal use
- Install dependencies from requirements.txt
- Install **pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib**
- Basic setup guide https://developers.google.com/sheets/api/quickstart/python
- Required Environment details
- ENV variable SPREADSHEET_ID: provide the google sheet ID
- ENV variable SHEET_CELLS: cell range in format '!F35:G48'
- place the credentials.json file having google sheets details in the folder src/main/config

# Analysis - My Datascience application
- install streamlit, pandas, matplotlib
- place the data excel file at the location <my-utils\src\main\data>
- run streamlit main.py as below
- open the browser with the given local IP address
- place the credentials.json file having google sheets details in the folder <src/main/config>
- set the environment variables appropriately

# Run
- python -s -m src.main.expense_analysis.expense_analyzer
- python -s - m src.main.util.website_sanity_test
- python -m streamlit run src/main/expense_analysis/main.py
- Data Load
- SET ENV variable LOAD_TYPE to full/incremental
- RUN python3 -m src.main.data.data_import
- RUN Streamlit server
- python -m streamlit run src/main/analyse/main.py
Binary file modified requirements.txt
Binary file not shown.
File renamed without changes.
File renamed without changes.
61 changes: 61 additions & 0 deletions src/main/analyse/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import streamlit as st
from dotenv import load_dotenv

from src.main.data.core_data import CoreData
from src.main.data.data_import import ImportData
from loguru import logger
from streamlit_echarts import st_echarts

from src.main.data.sqlite_conn import Sql
from src.main.utils.utils import Utils

load_dotenv()


# streamlit app
st.title('My Analytics')
st.markdown("# Home 🎈")
st.sidebar.markdown("# Home 🎈")
# Create a text element and let the reader know the data is loading.
data_load_state = st.text('Loading data...')


# @st.cache_data
def get_data():
return Sql().get_data_from_table(query=f"select * from Jul2023 where Date = 'Jul2023'")


data = get_data()

# Notify the reader that the data was successfully loaded.

bardf = Sql().get_data_from_table(query=f"select * from {Utils().get_current_month_year()} where Date = "
f"'{Utils().get_current_month_year()}'")
home_bar = bardf['Home'].values[0]
bills_bar = bardf['Bills'].values[0]
shopping_bar = bardf['Shopping'].values[0]
food_bar = bardf['Food'].values[0]
travel_bar = bardf['Travel'].values[0]
clothes_bar = bardf['Clothes'].values[0]
fuel_bar = bardf['Fuel'].values[0]
gifts_bar = bardf['Gifts'].values[0]
general_bar = bardf['General'].values[0]
invest_bar = bardf['Investment'].values[0]
meds_bar = bardf['Medicine'].values[0]


options = {
"xAxis": {
"type": "category",
"data": CoreData().columns,
},
"yAxis": {"type": "value"},
"series": [{"data": [home_bar, bills_bar, shopping_bar, food_bar, travel_bar, clothes_bar,
fuel_bar, gifts_bar, general_bar, invest_bar, meds_bar],
"type": "bar"}],
}

st.write("# Current Month")
st_echarts(options=options, height="500px")

data_load_state.text(f'Data for the current month')
26 changes: 26 additions & 0 deletions src/main/analyse/pages/monthly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import streamlit as st
import pandas as pd
from src.main.data.core_data import CoreData
from src.main.data.sqlite_conn import Sql

st.markdown("# Monthly Chart ❄️")
st.sidebar.markdown("# Monthly Chart ❄️")

data_load_state = st.text('Loading data...')
data_load_state.text(f'Data for the months of 2023')

df_jul2023 = Sql().get_data_from_table(query=f"select * from Jul2023 where Date = 'Jul2023'")
df_jun2023 = Sql().get_data_from_table(query=f"select * from Jun2023 where Date = 'Jun2023'")
df_may2023 = Sql().get_data_from_table(query=f"select * from May2023 where Date = 'May2023'")
df_apr2023 = Sql().get_data_from_table(query=f"select * from Apr2023 where Date = 'Apr2023'")
df_mar2023 = Sql().get_data_from_table(query=f"select * from Mar2023 where Date = 'Mar2023'")
df_feb2023 = Sql().get_data_from_table(query=f"select * from Feb2023 where Date = 'Feb2023'")
df_jan2023 = Sql().get_data_from_table(query=f"select * from Jan2023 where Date = 'Jan2023'")

frames = [df_jul2023, df_jun2023, df_may2023, df_apr2023, df_mar2023,
df_feb2023, df_jan2023]
df_merged = pd.concat(frames)
st.write(df_merged)
for each in CoreData().columns:
st.line_chart(data=df_merged, x='Date', y=[each],
width=0, height=0, use_container_width=True)
3 changes: 3 additions & 0 deletions src/main/data/core_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class CoreData:
columns = ["Home", "Bills", "Shopping", "Food", "Travel", "Clothes",
"Fuel", "Gifts", "General", "Investment", "Medicine"]
36 changes: 0 additions & 36 deletions src/main/ea/main.py

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/ea/pages/monthly.py

This file was deleted.

0 comments on commit 746cd9a

Please sign in to comment.