-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsupport_functions.py
More file actions
90 lines (69 loc) · 4.6 KB
/
support_functions.py
File metadata and controls
90 lines (69 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""
Copyright [2020] [Sinisa Seslak (seslaks@gmail.com)]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
"""
Support functions for modules in CredPy (https://github.com/seslak/CredPy)
"""
# Function for calculating weights in dataset
def weight(args, c, dataset, modeldataset):
import pandas as pd
x = pd.DataFrame.std(modeldataset)[args[args.index(c)]]/pd.DataFrame.std(dataset)[args[args.index(c)]]
return (x)
# Function for building the balance sheet and P&L and appending it to the dataset
def crappend(args):
import pandas as pd
x = pd.DataFrame(args, columns = ['cash', # Cash and Cash equivalents
'receivables', # Receivables
'inventory', # Inventory
'otherstassets', # Other short-term assets
'equipment', # Equipment
'buildings', # Buildings and machinery
'land', # Land
'otherltassets', # Other long-term assets
'defferedtax', # Deffered Taxes
'lossaboveq', # Loss above equity level
'payables', # Payables
'stloans', # Shor-term loans
'ltloansyear', # Long-term loans part maturing within a year
'otherstobl', # Other short-term obligations
'ltloans', # Long-term loans
'otherltobl', # Other long-term obligations
'paidincap', # Paid in capital
'retainedear', # Retained earnings
'othcap', # Other capital
'revenues', # Total revenues
'cogs', # Costs of goods sold
'gna', # General and administration costs
'salaries', # Total salaries
'amortization', # Amortization
'othopexp', # Other operating expenses
'interest', # Interest expanses
'othrev', # Other revenues
'othexp', # Other expenses
'taxes', # Taxes
'othchg']) # Other P&L Changes
# Basic balance sheet positions
x['tlta'] = x['equipment']+x['buildings']+x['land']+x['otherltassets'] # Total long-term assets
x['tsta'] = x['cash'] + x['receivables'] + x['inventory'] + x['otherstassets'] # Total short-term assets
x['ta'] = x['tlta'] + x['tsta'] - x['defferedtax'] - x['lossaboveq']# Total assets
x['tso'] = x['payables'] + x['stloans'] + x['ltloansyear'] + x['otherstobl'] # Total shor-term obligations
x['tli'] = x['tso'] + x['ltloans'] + x['otherltobl'] # Total liabilities
x['equity'] = x['paidincap'] + x['retainedear'] + x['othcap'] # Total equity
# Basic P&L positions
x['totalcosts'] = x['cogs'] + x['gna'] + x['salaries'] + x['amortization'] + x['othopexp'] # Total costs
# Advanced P&L positions
x['ebitdar'] = x['revenues'] - x['cogs'] - x['salaries'] # EBITDAR
x['ebitda'] = x['ebitdar'] - x['gna'] - x['othopexp'] # EBITDA
x['ebit'] = x['ebitda'] - x['amortization'] # EBIT
x['ebt'] = x['ebit'] - x['interest'] + x['othrev'] + x['othexp'] # EBT
x['netincome'] = x['ebt'] - x['taxes'] # Net Income
return (x)