In [1]:
import sys
sys.path.append('../')
import mustaching as ms
%load_ext autoreload
%autoreload 2
In [2]:
# Invent some sample transactions.
transactions = ms.create_transactions('2017-01-01', '2017-12-31')
# Alternatively, upload your own transactions as say 'my_transactions.csv'
#transactions = ms.read_transactions('my_transactions.csv')
transactions.head(10)
Out[2]:
date
amount
description
comment
category
0
2017-01-01 00:00:00
-12
0x40cb4
0xeef97ae919
soil testing
1
2017-01-01 12:00:00
-42
0x37016
0x791b45e31d
food
2
2017-01-02 00:00:00
-35
0xf237d
0xaece5b6490
soil testing
3
2017-01-02 12:00:00
-8
0x8b00d
0xb078bdb34
food
4
2017-01-03 00:00:00
89
0x27eab
0xa0e3b3d9f9
reiki
5
2017-01-03 12:00:00
6
0x9545d
0xf0f61d8893
programming
6
2017-01-04 00:00:00
77
0x34c7e
0x36d4af809c
investing
7
2017-01-04 12:00:00
-3
0xd737d
0x251549267a
food
8
2017-01-05 00:00:00
-16
0x54623
0xaf503171aa
food
9
2017-01-05 12:00:00
1
0xcfb46
0xa7746bc573
programming
In [4]:
# Summarize over entire period by category
s1 = ms.summarize(transactions, by_category=True)
s1
Out[4]:
date
category
income
expense
balance
savings_pc_for_period
spending_pc_for_period
spending_pc_for_period_and_category
income_pc_for_period_and_category
expense_pc_for_period_and_category
daily_avg
weekly_avg
monthly_avg
yearly_avg
0
2017-01-01
food
0
1364
13215
58.67
41.33
6.06
0.00
14.65
-3.74
-26.16
-113.67
-1364.0
1
2017-01-01
healthcare
0
1390
13215
58.67
41.33
6.17
0.00
14.93
-3.81
-26.66
-115.83
-1390.0
2
2017-01-01
investing
6383
0
13215
58.67
41.33
0.00
28.34
0.00
17.49
122.41
531.92
6383.0
3
2017-01-01
programming
11048
0
13215
58.67
41.33
0.00
49.05
0.00
30.27
211.88
920.67
11048.0
4
2017-01-01
reiki
5093
0
13215
58.67
41.33
0.00
22.61
0.00
13.95
97.67
424.42
5093.0
5
2017-01-01
shelter
0
2914
13215
58.67
41.33
12.94
0.00
31.30
-7.98
-55.88
-242.83
-2914.0
6
2017-01-01
soil testing
0
1809
13215
58.67
41.33
8.03
0.00
19.43
-4.96
-34.69
-150.75
-1809.0
7
2017-01-01
transport
0
1832
13215
58.67
41.33
8.13
0.00
19.68
-5.02
-35.13
-152.67
-1832.0
In [5]:
ms.plot(s1)
Out[5]:
In [6]:
# Summarize by month start
s2 = ms.summarize(transactions, freq='MS', by_category=False)
s2
Out[6]:
date
income
expense
balance
savings_pc_for_period
spending_pc_for_period
0
2017-01-01
2027
758
1269
62.60
37.40
1
2017-02-01
942
901
1310
4.35
95.65
2
2017-03-01
2137
864
2583
59.57
40.43
3
2017-04-01
1601
796
3388
50.28
49.72
4
2017-05-01
1805
817
4376
54.74
45.26
5
2017-06-01
2015
749
5642
62.83
37.17
6
2017-07-01
2035
624
7053
69.34
30.66
7
2017-08-01
1831
950
7934
48.12
51.88
8
2017-09-01
2053
607
9380
70.43
29.57
9
2017-10-01
1935
839
10476
56.64
43.36
10
2017-11-01
2007
616
11867
69.31
30.69
11
2017-12-01
2136
788
13215
63.11
36.89
In [7]:
ms.plot(s2)
Out[7]:
In [10]:
# Summarize by quarter start and by category
s3 = ms.summarize(transactions, freq='QS', by_category=True)
s3
Out[10]:
date
category
income
expense
balance
savings_pc_for_period
spending_pc_for_period
spending_pc_for_period_and_category
income_pc_for_period_and_category
expense_pc_for_period_and_category
0
2017-01-01
food
0
373
2583
50.59
49.41
7.31
0.00
14.78
1
2017-01-01
healthcare
0
598
2583
50.59
49.41
11.71
0.00
23.70
2
2017-01-01
investing
1710
0
2583
50.59
49.41
0.00
33.49
0.00
3
2017-01-01
programming
2423
0
2583
50.59
49.41
0.00
47.45
0.00
4
2017-01-01
reiki
973
0
2583
50.59
49.41
0.00
19.06
0.00
5
2017-01-01
shelter
0
593
2583
50.59
49.41
11.61
0.00
23.50
6
2017-01-01
soil testing
0
332
2583
50.59
49.41
6.50
0.00
13.16
7
2017-01-01
transport
0
627
2583
50.59
49.41
12.28
0.00
24.85
8
2017-04-01
food
0
427
5642
56.43
43.57
7.88
0.00
18.08
9
2017-04-01
healthcare
0
234
5642
56.43
43.57
4.32
0.00
9.91
10
2017-04-01
investing
1969
0
5642
56.43
43.57
0.00
36.32
0.00
11
2017-04-01
programming
2279
0
5642
56.43
43.57
0.00
42.04
0.00
12
2017-04-01
reiki
1173
0
5642
56.43
43.57
0.00
21.64
0.00
13
2017-04-01
shelter
0
798
5642
56.43
43.57
14.72
0.00
33.78
14
2017-04-01
soil testing
0
472
5642
56.43
43.57
8.71
0.00
19.98
15
2017-04-01
transport
0
431
5642
56.43
43.57
7.95
0.00
18.25
16
2017-07-01
food
0
194
9380
63.15
36.85
3.28
0.00
8.90
17
2017-07-01
healthcare
0
346
9380
63.15
36.85
5.85
0.00
15.86
18
2017-07-01
investing
1513
0
9380
63.15
36.85
0.00
25.56
0.00
19
2017-07-01
programming
2957
0
9380
63.15
36.85
0.00
49.96
0.00
20
2017-07-01
reiki
1449
0
9380
63.15
36.85
0.00
24.48
0.00
21
2017-07-01
shelter
0
765
9380
63.15
36.85
12.92
0.00
35.08
22
2017-07-01
soil testing
0
467
9380
63.15
36.85
7.89
0.00
21.41
23
2017-07-01
transport
0
409
9380
63.15
36.85
6.91
0.00
18.75
24
2017-10-01
food
0
370
13215
63.10
36.90
6.09
0.00
16.50
25
2017-10-01
healthcare
0
212
13215
63.10
36.90
3.49
0.00
9.45
26
2017-10-01
investing
1191
0
13215
63.10
36.90
0.00
19.60
0.00
27
2017-10-01
programming
3389
0
13215
63.10
36.90
0.00
55.76
0.00
28
2017-10-01
reiki
1498
0
13215
63.10
36.90
0.00
24.65
0.00
29
2017-10-01
shelter
0
758
13215
63.10
36.90
12.47
0.00
33.79
30
2017-10-01
soil testing
0
538
13215
63.10
36.90
8.85
0.00
23.99
31
2017-10-01
transport
0
365
13215
63.10
36.90
6.01
0.00
16.27
In [11]:
ms.plot(s3)
Out[11]:
In [ ]:
Content source: araichev/budgeting
Similar notebooks: