Change net income figure; Add table
This commit is contained in:
parent
7c75bd3c37
commit
e9a218bb88
@ -23,13 +23,24 @@ def _compute_total_balance(df: pd.DataFrame) -> pd.DataFrame:
|
|||||||
|
|
||||||
|
|
||||||
def _compute_net_income(df: pd.DataFrame) -> pd.DataFrame:
|
def _compute_net_income(df: pd.DataFrame) -> pd.DataFrame:
|
||||||
stripped_df = pd.DataFrame({'t': df["t"], 'value': df["value"]})
|
df.index = df['t']
|
||||||
|
income_df = df.loc[df['value'] > 0]
|
||||||
|
expenses_df = df.loc[df['value'] < 0]
|
||||||
|
|
||||||
stripped_df.index = stripped_df['t']
|
income_df = income_df.groupby(pd.Grouper(freq='M'))[
|
||||||
gb = stripped_df.groupby(pd.Grouper(freq='M'))
|
'value'].sum().reset_index().round(decimals=2)
|
||||||
|
expenses_df = expenses_df.groupby(pd.Grouper(freq='M'))[
|
||||||
|
'value'].sum().reset_index().round(decimals=2)
|
||||||
|
|
||||||
result = gb["value"].sum().reset_index()
|
t = income_df['t']
|
||||||
return result
|
income = income_df['value'].round(decimals=2)
|
||||||
|
expenses = expenses_df['value'].round(decimals=2)
|
||||||
|
net = (income + expenses).round(decimals=2)
|
||||||
|
|
||||||
|
result_df = pd.DataFrame(
|
||||||
|
{'t': t, 'income': income, 'expenses': expenses, 'net': net})
|
||||||
|
|
||||||
|
return result_df
|
||||||
|
|
||||||
|
|
||||||
def _compute_category_overview(df: pd.DataFrame) -> pd.DataFrame:
|
def _compute_category_overview(df: pd.DataFrame) -> pd.DataFrame:
|
||||||
@ -46,11 +57,12 @@ def _compute_category_overview(df: pd.DataFrame) -> pd.DataFrame:
|
|||||||
|
|
||||||
category_overview_df = category_overview_df.sort_values('value',
|
category_overview_df = category_overview_df.sort_values('value',
|
||||||
ascending=False)
|
ascending=False)
|
||||||
|
|
||||||
return category_overview_df
|
return category_overview_df
|
||||||
|
|
||||||
|
|
||||||
def _compute_expenses_by_category(complete_df: pd.DataFrame) -> pd.DataFrame:
|
def _compute_expenses_by_category(complete_df: pd.DataFrame) -> pd.DataFrame:
|
||||||
complete_df = complete_df.loc[complete_df['value'] < 0]
|
complete_df = complete_df.loc[complete_df['value'] < 0].copy()
|
||||||
complete_df['value'] = -complete_df['value']
|
complete_df['value'] = -complete_df['value']
|
||||||
complete_df.index = complete_df['t']
|
complete_df.index = complete_df['t']
|
||||||
|
|
||||||
|
|||||||
@ -157,7 +157,7 @@
|
|||||||
]
|
]
|
||||||
% Dummy plot to set x axis ticks
|
% Dummy plot to set x axis ticks
|
||||||
\addplot[draw=none]
|
\addplot[draw=none]
|
||||||
table[col sep=comma, x=t, y=value]
|
table[col sep=comma, x=t, y=net]
|
||||||
{net_income.csv};
|
{net_income.csv};
|
||||||
|
|
||||||
% Dummy plot to set x axis scale
|
% Dummy plot to set x axis scale
|
||||||
@ -165,11 +165,17 @@
|
|||||||
table[col sep=comma, x=t, y expr=0]
|
table[col sep=comma, x=t, y expr=0]
|
||||||
{detailed_balance.csv};
|
{detailed_balance.csv};
|
||||||
|
|
||||||
\addplot[ybar, color=scol2, fill=scol2, line width=1pt]
|
\addplot[ybar, bar width=0.4cm, draw=none, fill=scol2!30, line width=1pt]
|
||||||
table[col sep=comma, x=t, y=value, discard if lt={value}{0}]
|
table[col sep=comma, x=t, y=income]
|
||||||
{net_income.csv};
|
{net_income.csv};
|
||||||
\addplot[ybar, color=scol0, fill=scol0, line width=1pt]
|
\addplot[ybar, bar width=0.4cm, draw=none, fill=scol0!30, line width=1pt]
|
||||||
table[col sep=comma, x=t, y=value, discard if gt={value}{0}]
|
table[col sep=comma, x=t, y=expenses]
|
||||||
|
{net_income.csv};
|
||||||
|
\addplot[ybar, bar width=0.3cm, draw=none, fill=scol0, line width=1pt]
|
||||||
|
table[col sep=comma, x=t, y=net, discard if gt={net}{0}]
|
||||||
|
{net_income.csv};
|
||||||
|
\addplot[ybar, bar width=0.3cm, draw=none, fill=scol2, line width=1pt]
|
||||||
|
table[col sep=comma, x=t, y=net, discard if lt={net}{0}]
|
||||||
{net_income.csv};
|
{net_income.csv};
|
||||||
\end{axis}
|
\end{axis}
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
@ -211,6 +217,13 @@
|
|||||||
\caption{Development of account balance over time}
|
\caption{Development of account balance over time}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
|
\begin{figure}
|
||||||
|
\centering
|
||||||
|
|
||||||
|
|
||||||
|
\csvautotabular{net_income.csv}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
|
||||||
\begin{figure}[H]
|
\begin{figure}[H]
|
||||||
\centering
|
\centering
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user