Skip to main content

The Ultimate Metric Library

Project description

Metric Forge

Description of the image

Metric Forge is your ultimate toolkit for measuring and evaluating performance across various business domains.

Disclaimer

Metric Forge provides a collection of calculations across various domains, including finance, mortgage, marketing, and more. While every effort has been made to ensure the accuracy and reliability of the calculations and methods provided, Metric Forge is intended for informational and educational purposes only.

Important Notice:

No Warranty: The calculations and methods provided in this package are offered "as-is" without any guarantees or warranties of any kind, either express or implied. The package's creators do not assume any responsibility for errors or omissions or for any damages resulting from the use of the package.

Not Professional Advice: The results produced by the package should not be considered as professional financial, investment, legal, or any other type of advice. Users should consult with qualified professionals before making any decisions based on the outputs generated by this package.

Use at Your Own Risk: Users of Metric Forge assume full responsibility for the use of the package and its results. The creators of the package shall not be held liable for any decisions made based on the information provided or for any consequences arising from the use of the package.

By using this package, you acknowledge and agree to this disclaimer. If you do not agree, please refrain from using the Metric Forge package.

Getting Started

install the package via pip

pip install metric-forge

Ecommerce

You can use Ecommerce Metrics in two different ways:

  • With Polars
  • As a Single Value Function (SVF)

Metric Forge extends the Polars expression library; making it possible to perform row-wise-calculations for various metrics. In addition to mass calculations, you can also perform single value calculations that return just one value.

from metric_forge.ecommerce import * 
import polars as pl
data = pl.read_csv('datasets/ecommerce_metrics.csv')
data.head()
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (5, 15)
monthtotal_revenuenumber_of_orderscost_of_acquisitionnew_customerscarts_createdcompleted_purchasesrevenue_from_adsadvertising_spendnum_conversionsnum_visitorsrevenue_per_customeraverage_customer_lifetimenum_customers_losttotal_customers_beginning
strf64i64f64i64i64i64f64f64i64i64f64f64i64i64
"2023-01"87454.01188599122958.3505594061969142581339.9576965390.91016930013154202.4273293.1593642393306
"2023-02"145071.43064191318736.8742062341506142176875.08340215585.03701842714762116.1734361.8122451244680
"2023-03"123199.394181130528355.5868421201497965116505.48219114872.03795436710056384.2651564.7714141774675
"2023-04"109865.8484288514184.8158242819631102106008.04638112337.20436813219948144.3563283.3954622992972
"2023-05"65601.86404469118764.339456266100980197258.8099125351.99556814713110275.7346013.779142963768

Customer Acquisition Cost

data.with_columns(pl.col('*').forge_ecommerce.customer_acquisition_cost('cost_of_acquisition', 'new_customers'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (12, 16)
monthtotal_revenuenumber_of_orderscost_of_acquisitionnew_customerscarts_createdcompleted_purchasesrevenue_from_adsadvertising_spendnum_conversionsnum_visitorsrevenue_per_customeraverage_customer_lifetimenum_customers_losttotal_customers_beginningcustomer_acquisition_cost
strf64i64f64i64i64i64f64f64i64i64f64f64i64i64f64
"2023-01"87454.01188599122958.3505594061969142581339.9576965390.91016930013154202.4273293.159364239330656.547661
"2023-02"145071.43064191318736.8742062341506142176875.08340215585.03701842714762116.1734361.812245124468080.072112
"2023-03"123199.394181130528355.5868421201497965116505.48219114872.03795436710056384.2651564.7714141774675236.296557
"2023-04"109865.8484288514184.8158242819631102106008.04638112337.20436813219948144.3563283.395462299297233.142093
"2023-05"65601.86404469118764.339456266100980197258.8099125351.99556814713110275.7346013.77914296376870.54263
"2023-08"136617.61457766033555.2788421881108601116872.97765424754.3885133928840290.1480892.1825352803479178.485526
"2023-09"110111.50117495915990.2134654151975139584633.08229220148.999371986028325.3102291.421977239343438.530635
"2023-10"120807.2577881325427.03315211380066954839.92638228157.52196327112385378.2064352.8261382742648225.017992
"2023-11"52058.4494352127772.4370663412005121556664.61551321276.9256384595502155.7325821.873762178231781.444097
"2023-12"146990.98521675211393.512382364170485544874.02451627873.99188931311910341.7669522.66604170325731.300858

Average Order Value

data.with_columns(pl.col('*').forge_ecommerce.average_order_value('total_revenue', 'number_of_orders'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (12, 16)
monthtotal_revenuenumber_of_orderscost_of_acquisitionnew_customerscarts_createdcompleted_purchasesrevenue_from_adsadvertising_spendnum_conversionsnum_visitorsrevenue_per_customeraverage_customer_lifetimenum_customers_losttotal_customers_beginningaverage_order_value
strf64i64f64i64i64i64f64f64i64i64f64f64i64i64f64
"2023-01"87454.01188599122958.3505594061969142581339.9576965390.91016930013154202.4273293.159364239330688.248246
"2023-02"145071.43064191318736.8742062341506142176875.08340215585.03701842714762116.1734361.8122451244680158.895324
"2023-03"123199.394181130528355.5868421201497965116505.48219114872.03795436710056384.2651564.771414177467594.405666
"2023-04"109865.8484288514184.8158242819631102106008.04638112337.20436813219948144.3563283.3954622992972124.142202
"2023-05"65601.86404469118764.339456266100980197258.8099125351.99556814713110275.7346013.77914296376894.937575
"2023-08"136617.61457766033555.2788421881108601116872.97765424754.3885133928840290.1480892.1825352803479206.996386
"2023-09"110111.50117495915990.2134654151975139584633.08229220148.999371986028325.3102291.4219772393434114.819084
"2023-10"120807.2577881325427.03315211380066954839.92638228157.52196327112385378.2064352.8261382742648148.594413
"2023-11"52058.4494352127772.4370663412005121556664.61551321276.9256384595502155.7325821.873762178231799.920248
"2023-12"146990.98521675211393.512382364170485544874.02451627873.99188931311910341.7669522.666041703257195.466736

Cart Abandonment Rate

data.with_columns(pl.col('*').forge_ecommerce.cart_abandonment_rate('carts_created', 'completed_purchases'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (12, 16)
monthtotal_revenuenumber_of_orderscost_of_acquisitionnew_customerscarts_createdcompleted_purchasesrevenue_from_adsadvertising_spendnum_conversionsnum_visitorsrevenue_per_customeraverage_customer_lifetimenum_customers_losttotal_customers_beginningcart_abandonment_rate
strf64i64f64i64i64i64f64f64i64i64f64f64i64i64f64
"2023-01"87454.01188599122958.3505594061969142581339.9576965390.91016930013154202.4273293.159364239330627.628238
"2023-02"145071.43064191318736.8742062341506142176875.08340215585.03701842714762116.1734361.81224512446805.64409
"2023-03"123199.394181130528355.5868421201497965116505.48219114872.03795436710056384.2651564.771414177467535.537742
"2023-04"109865.8484288514184.8158242819631102106008.04638112337.20436813219948144.3563283.395462299297243.861437
"2023-05"65601.86404469118764.339456266100980197258.8099125351.99556814713110275.7346013.77914296376820.61447
"2023-08"136617.61457766033555.2788421881108601116872.97765424754.3885133928840290.1480892.182535280347945.758123
"2023-09"110111.50117495915990.2134654151975139584633.08229220148.999371986028325.3102291.421977239343429.367089
"2023-10"120807.2577881325427.03315211380066954839.92638228157.52196327112385378.2064352.826138274264816.375
"2023-11"52058.4494352127772.4370663412005121556664.61551321276.9256384595502155.7325821.873762178231739.401496
"2023-12"146990.98521675211393.512382364170485544874.02451627873.99188931311910341.7669522.66604170325749.823944

Return on Advertising Spend

data.with_columns(pl.col('*').forge_ecommerce.return_on_advertising_spend('revenue_from_ads', 'advertising_spend'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (12, 16)
monthtotal_revenuenumber_of_orderscost_of_acquisitionnew_customerscarts_createdcompleted_purchasesrevenue_from_adsadvertising_spendnum_conversionsnum_visitorsrevenue_per_customeraverage_customer_lifetimenum_customers_losttotal_customers_beginningreturn_on_advertising_spend
strf64i64f64i64i64i64f64f64i64i64f64f64i64i64f64
"2023-01"87454.01188599122958.3505594061969142581339.9576965390.91016930013154202.4273293.159364239330615.088353
"2023-02"145071.43064191318736.8742062341506142176875.08340215585.03701842714762116.1734361.81224512446804.932621
"2023-03"123199.394181130528355.5868421201497965116505.48219114872.03795436710056384.2651564.77141417746757.833861
"2023-04"109865.8484288514184.8158242819631102106008.04638112337.20436813219948144.3563283.39546229929728.59255
"2023-05"65601.86404469118764.339456266100980197258.8099125351.99556814713110275.7346013.77914296376818.172438
"2023-08"136617.61457766033555.2788421881108601116872.97765424754.3885133928840290.1480892.18253528034794.721303
"2023-09"110111.50117495915990.2134654151975139584633.08229220148.999371986028325.3102291.42197723934344.200362
"2023-10"120807.2577881325427.03315211380066954839.92638228157.52196327112385378.2064352.82613827426481.947612
"2023-11"52058.4494352127772.4370663412005121556664.61551321276.9256384595502155.7325821.87376217823172.663196
"2023-12"146990.98521675211393.512382364170485544874.02451627873.99188931311910341.7669522.6660417032571.609889

Conversion Rate

data.with_columns(pl.col('*').forge_ecommerce.conversion_rate('num_conversions', 'num_visitors'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (12, 16)
monthtotal_revenuenumber_of_orderscost_of_acquisitionnew_customerscarts_createdcompleted_purchasesrevenue_from_adsadvertising_spendnum_conversionsnum_visitorsrevenue_per_customeraverage_customer_lifetimenum_customers_losttotal_customers_beginningconversion_rate
strf64i64f64i64i64i64f64f64i64i64f64f64i64i64f64
"2023-01"87454.01188599122958.3505594061969142581339.9576965390.91016930013154202.4273293.15936423933062.280675
"2023-02"145071.43064191318736.8742062341506142176875.08340215585.03701842714762116.1734361.81224512446802.892562
"2023-03"123199.394181130528355.5868421201497965116505.48219114872.03795436710056384.2651564.77141417746753.649562
"2023-04"109865.8484288514184.8158242819631102106008.04638112337.20436813219948144.3563283.39546229929720.66172
"2023-05"65601.86404469118764.339456266100980197258.8099125351.99556814713110275.7346013.7791429637681.121281
"2023-08"136617.61457766033555.2788421881108601116872.97765424754.3885133928840290.1480892.18253528034794.434389
"2023-09"110111.50117495915990.2134654151975139584633.08229220148.999371986028325.3102291.42197723934343.284672
"2023-10"120807.2577881325427.03315211380066954839.92638228157.52196327112385378.2064352.82613827426482.188131
"2023-11"52058.4494352127772.4370663412005121556664.61551321276.9256384595502155.7325821.87376217823178.342421
"2023-12"146990.98521675211393.512382364170485544874.02451627873.99188931311910341.7669522.6660417032572.628044

Customer Lifetime Value

data.with_columns(pl.col('*').forge_ecommerce.customer_lifetime_value('revenue_per_customer', 'average_customer_lifetime'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (12, 16)
monthtotal_revenuenumber_of_orderscost_of_acquisitionnew_customerscarts_createdcompleted_purchasesrevenue_from_adsadvertising_spendnum_conversionsnum_visitorsrevenue_per_customeraverage_customer_lifetimenum_customers_losttotal_customers_beginningcustomer_lifetime_value
strf64i64f64i64i64i64f64f64i64i64f64f64i64i64f64
"2023-01"87454.01188599122958.3505594061969142581339.9576965390.91016930013154202.4273293.1593642393306639.54169
"2023-02"145071.43064191318736.8742062341506142176875.08340215585.03701842714762116.1734361.8122451244680210.534716
"2023-03"123199.394181130528355.5868421201497965116505.48219114872.03795436710056384.2651564.77141417746751833.488253
"2023-04"109865.8484288514184.8158242819631102106008.04638112337.20436813219948144.3563283.3954622992972490.156408
"2023-05"65601.86404469118764.339456266100980197258.8099125351.99556814713110275.7346013.7791429637681042.039585
"2023-08"136617.61457766033555.2788421881108601116872.97765424754.3885133928840290.1480892.1825352803479633.258286
"2023-09"110111.50117495915990.2134654151975139584633.08229220148.999371986028325.3102291.4219772393434462.583676
"2023-10"120807.2577881325427.03315211380066954839.92638228157.52196327112385378.2064352.82613827426481068.863683
"2023-11"52058.4494352127772.4370663412005121556664.61551321276.9256384595502155.7325821.8737621782317291.805755
"2023-12"146990.98521675211393.512382364170485544874.02451627873.99188931311910341.7669522.666041703257911.164293

Product Development

You can use Product Development Metrics in two different ways:

  • With Polars
  • As a Single Value Function (SVF)

Metric Forge extends the Polars expression library; making it possible to perform row-wise-calculations for various metrics. In addition to mass calculations, you can also perform single value calculations that return just one value.

import polars as pl
data = pl.read_csv('datasets/customer-value.csv')
data
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (10, 3)
feature_nameimportance_scoresatisfaction_score
stri64i64
"Feature1"87
"Feature2"68
"Feature3"79
"Feature4"87
"Feature5"66
"Feature6"98
"Feature7"79
"Feature8"67
"Feature9"98
"Feature10"87

Underserved Customer Needs

from metric_forge.product_development import *


data.with_columns(pl.col('*').forge_product_dev.opportunity_score(importance_col='importance_score',satisfaction_col='satisfaction_score'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (10, 4)
feature_nameimportance_scoresatisfaction_scoreopportunity_score
stri64i64f64
"Feature1"879.0
"Feature2"684.0
"Feature3"795.0
"Feature4"879.0
"Feature5"666.0
"Feature6"9810.0
"Feature7"795.0
"Feature8"675.0
"Feature9"9810.0
"Feature10"879.0
data.with_columns(pl.col('*').forge_product_dev.customer_value_delivered(importance_col='importance_score',satisfaction_col='satisfaction_score'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (10, 4)
feature_nameimportance_scoresatisfaction_scorecustomer_value_delivered
stri64i64f64
"Feature1"870.56
"Feature2"680.48
"Feature3"790.63
"Feature4"870.56
"Feature5"660.36
"Feature6"980.72
"Feature7"790.63
"Feature8"670.42
"Feature9"980.72
"Feature10"870.56
data.with_columns(pl.col('*').forge_product_dev.opportunity_to_add_value(importance_col='importance_score',satisfaction_col='satisfaction_score'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (10, 4)
feature_nameimportance_scoresatisfaction_scoreopp_to_add_value
stri64i64f64
"Feature1"870.24
"Feature2"680.12
"Feature3"790.07
"Feature4"870.24
"Feature5"660.24
"Feature6"980.18
"Feature7"790.07
"Feature8"670.18
"Feature9"980.18
"Feature10"870.24
import polars as pl
data = pl.read_csv('datasets/customer-value-added.csv')
data
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (10, 4)
feature_nameimportance_scoresatisfaction_score_beforesatisfaction_score_after
stri64i64i64
"Feature1"879
"Feature2"989
"Feature3"798
"Feature4"878
"Feature5"668
"Feature6"989
"Feature7"798
"Feature8"676
"Feature9"988
"Feature10"877
data.with_columns(pl.col('*').forge_product_dev.customer_value_created(importance_col='importance_score'
                       ,satisfaction_after_col='satisfaction_score_after'
                       ,satisfaction_before_col='satisfaction_score_before'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (10, 5)
feature_nameimportance_scoresatisfaction_score_beforesatisfaction_score_aftercustomer_value_created
stri64i64i64f64
"Feature1"8790.16
"Feature2"9890.09
"Feature3"798-0.07
"Feature4"8780.08
"Feature5"6680.12
"Feature6"9890.09
"Feature7"798-0.07
"Feature8"676-0.06
"Feature9"9880.0
"Feature10"8770.0

Finance

The Finance module contains financial statement objects that you can call certain methods off of to get key financial metrics. You need to define these objects prior to running calcuations.

Financial Statement Objects

from metric_forge import *

fs = import_financials(ticker='MAR',engine='yfinance')
fs

Income Statement

<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (5, 49)
dateTax Effect Of Unusual ItemsTax Rate For CalcsNormalized EBITDATotal Unusual ItemsTotal Unusual Items Excluding GoodwillNet Income From Continuing Operation Net Minority InterestReconciled DepreciationReconciled Cost Of RevenueEBITDAEBITNet Interest IncomeInterest ExpenseInterest IncomeNormalized IncomeNet Income From Continuing And Discontinued OperationTotal ExpensesTotal Operating Income As ReportedDiluted Average SharesBasic Average SharesDiluted EPSBasic EPSDiluted NI Availto Com StockholdersNet Income Common StockholdersNet IncomeNet Income Including Noncontrolling InterestsNet Income Continuous OperationsTax ProvisionPretax IncomeOther Income ExpenseOther Non Operating Income ExpensesSpecial Income ChargesOther Special ChargesRestructuring And Mergern AcquisitionEarnings From Equity InterestNet Non Operating Interest Income ExpenseInterest Expense Non OperatingInterest Income Non OperatingOperating IncomeOperating ExpenseDepreciation Amortization Depletion Income StatementDepreciation And Amortization In Income StatementSelling General And AdministrationGeneral And Administrative ExpenseOther Gand AGross ProfitCost Of RevenueTotal RevenueOperating Revenue
strf64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64
"2023-12-31 00:00:00"-5.22e60.0874.2800e9-6e7-6e73.0830e92.77e81.8501e104.2200e93.9430e9-5.3500e85.65e83e73.1378e93.0830e91.9789e103.8640e93.029e83.015e810.1810.233.0830e93.0830e93.0830e93.0830e93.0830e92.95e83.3780e9-1.1e74e7-6e7null6e79e6-5.3500e85.65e83e73.9240e91.2000e91.89e81.89e81.0110e91.0110e91.0110e95.1240e91.8589e102.3713e106.3880e9
"2022-12-31 00:00:00"-2.916e60.2433.8110e9-1.2e7-1.2e72.3580e92.82e81.6126e103.7990e93.5170e9-3.7700e84.03e82.6e72.3671e92.3580e91.7299e103.4620e93.258e83.244e87.247.272.3580e92.3580e92.3580e92.3580e92.3580e97.56e83.1140e91.7e71.1e7-1.2e7null1.2e71.8e7-3.7700e84.03e82.6e73.4740e91.0840e91.93e81.93e88.91e88.91e88.91e84.5580e91.6215e102.0773e105.4450e9
"2021-12-31 00:00:00"-1.1696e70.0682.0670e9-1.7200e8-1.7200e81.0990e92.95e81.0981e101.8950e91.6000e9-3.9200e84.2e82.8e71.2593e91.0990e91.2099e101.7500e93.293e83.272e83.343.361.0990e91.0990e91.0990e91.0990e91.0990e98.1e71.1800e9-1.8600e81e7-1.7200e81.64e88e6-2.4e7-3.9200e84.2e82.8e71.7580e91.0430e92.2e82.2e88.23e88.23e88.23e82.8010e91.1056e101.3857e103.4900e9
"2020-12-31 00:00:00"-7.209e70.277.24e8-2.6700e8-2.6700e8-2.6700e84.78e88.9800e94.57e8-2.1e7-4.1800e84.45e82.7e7-7.209e7-2.6700e81.0220e108.4e73.258e83.258e8-0.82-0.82-2.6700e8-2.6700e8-2.6700e8-2.6700e8-2.6700e8-1.9900e8-4.6600e8-3.9900e89e6-2.6700e8null2.67e8-1.4100e8-4.1800e84.45e82.7e73.51e81.1080e93.46e83.46e87.62e87.62e87.62e81.4590e99.1120e91.0571e102.1190e9
"2019-12-31 00:00:00"nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull-1.5400e8nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull

Balance Sheet

<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (5, 69)
dateOrdinary Shares NumberShare IssuedNet DebtTotal DebtTangible Book ValueInvested CapitalWorking CapitalNet Tangible AssetsCapital Lease ObligationsCommon Stock EquityTotal CapitalizationTotal Equity Gross Minority InterestStockholders EquityGains Losses Not Affecting Retained EarningsOther Equity AdjustmentsTreasury StockRetained EarningsAdditional Paid In CapitalCapital StockCommon StockTotal Liabilities Net Minority InterestTotal Non Current Liabilities Net Minority InterestOther Non Current LiabilitiesNon Current Deferred LiabilitiesNon Current Deferred RevenueNon Current Deferred Taxes LiabilitiesLong Term Debt And Capital Lease ObligationLong Term Capital Lease ObligationLong Term DebtCurrent LiabilitiesOther Current LiabilitiesCurrent Debt And Capital Lease ObligationCurrent DebtPayables And Accrued ExpensesCurrent Accrued ExpensesPayablesAccounts PayableTotal AssetsTotal Non Current AssetsOther Non Current AssetsNon Current Deferred AssetsNon Current Deferred Taxes AssetsNon Current Note ReceivablesInvestments And AdvancesLong Term Equity InvestmentGoodwill And Other Intangible AssetsOther Intangible AssetsGoodwillNet PPEAccumulated DepreciationGross PPEConstruction In ProgressOther PropertiesMachinery Furniture EquipmentBuildings And ImprovementsLand And ImprovementsPropertiesCurrent AssetsOther Current AssetsAssets Held For Sale CurrentPrepaid AssetsReceivablesAccounts ReceivableAllowance For Doubtful Accounts ReceivableGross Accounts ReceivableCash Cash Equivalents And Short Term InvestmentsCash And Cash EquivalentsCash Financial
strf64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64
"2023-12-31 00:00:00"2.90539975e82.90539975e81.1535e101.2760e10-1.8758e101.1191e10-4.4510e9-1.8758e108.87e8-6.8200e81.0638e10-6.8200e8-6.8200e8-6.4700e8-6.4700e82.0929e101.4838e106.0510e95e65e62.6356e101.8594e105.1600e91.2270e91.0180e92.09e81.2207e108.87e81.1320e107.7620e93.3280e95.53e85.53e83.8810e93.1430e97.38e87.38e82.5674e102.2363e106.58e86.73e86.73e81.38e83.08e83.08e81.8076e109.1900e98.8860e92.5100e9-8.9000e83.4000e97.2e79.29e86.22e81.1080e96.69e80.03.3110e92.61e8nullnull2.7120e92.7120e9-1.9700e82.9090e93.38e83.38e8null
"2022-12-31 00:00:00"3.106e83.106e89.5570e91.1098e10-1.7051e101.0632e10-4.0260e9-1.7051e101.0340e95.68e89.9480e95.68e85.68e8-7.2900e8-7.2900e81.7015e101.2342e105.9650e95e65e62.4247e101.6908e105.1220e91.3720e91.0590e93.13e81.0414e101.0340e99.3800e97.3390e93.3140e96.84e86.84e83.3410e92.5950e97.46e87.46e82.4815e102.1502e105.84e82.4e82.4e81.52e83.35e83.35e81.7619e108.7470e98.8720e92.5720e9-8.7400e83.4460e93.6e79.87e86.49e81.0860e96.88e80.03.3130e92.35e8nullnull2.5710e92.5710e9-1.9100e82.7620e95.07e85.07e8null
"2021-12-31 00:00:00"3.273e83.273e88.7450e91.1236e10-1.6585e101.1552e10-2.7810e9-1.6585e101.0980e91.4140e91.0747e101.4140e91.4140e9-3.4200e8-3.4200e81.4446e101.0305e105.8920e95e65e62.4139e101.7732e105.9510e91.3500e91.1810e91.69e81.0431e101.0980e99.3330e96.4070e92.5220e98.05e88.05e83.0800e92.3540e97.26e87.26e82.5553e102.1927e106.04e82.28e82.28e81.44e83.87e83.87e81.7999e108.9260e99.0730e92.5650e9-8.5000e83.4150e91.37e81.0620e95.45e89.85e86.86e80.03.6260e92.51e8null2.51e81.9820e91.9820e9-1.8700e82.1690e91.3930e91.3930e9null
"2020-12-31 00:00:00"3.244e83.244e89.4990e91.1199e10-1.7734e101.0806e10-2.9270e9-1.7734e108.23e84.3e89.6330e94.3e84.3e8-1.3500e8-1.3500e81.4497e109.2060e95.8510e95e65e62.4271e101.8519e106.8680e91.6250e91.5420e98.3e71.0026e108.23e89.2030e95.7520e91.7690e91.1730e91.1730e92.8100e92.2830e95.27e85.27e82.4701e102.1876e106.16e82.49e82.49e81.59e84.22e8null1.8164e108.9890e99.1750e92.2660e9-8.8800e83.1540e92.9e77.52e86.4e81.0450e96.88e80.02.8250e91.8e88e61.8e81.7680e91.7680e9nullnull8.77e88.77e8null
"2019-12-31 00:00:00"nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull2.55e82.52e8nullnullnullnullnullnull2.25e8

Cash Flow

<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (5, 44)
dateFree Cash FlowRepurchase Of Capital StockRepayment Of DebtIssuance Of DebtIssuance Of Capital StockCapital ExpenditureEnd Cash PositionBeginning Cash PositionChanges In CashFinancing Cash FlowCash Flow From Continuing Financing ActivitiesNet Other Financing ChargesCash Dividends PaidCommon Stock Dividend PaidNet Common Stock IssuanceCommon Stock PaymentsCommon Stock IssuanceNet Issuance Payments Of DebtNet Short Term Debt IssuanceNet Long Term Debt IssuanceLong Term Debt PaymentsLong Term Debt IssuanceInvesting Cash FlowCash Flow From Continuing Investing ActivitiesNet Other Investing ChangesNet Business Purchase And SaleSale Of BusinessPurchase Of BusinessNet PPE Purchase And SaleSale Of PPECapital Expenditure ReportedOperating Cash FlowCash Flow From Continuing Operating ActivitiesChange In Working CapitalOther Non Cash ItemsStock Based CompensationDeferred TaxDeferred Income TaxDepreciation Amortization DepletionDepreciation And AmortizationDepreciationOperating Gains LossesNet Income From Continuing Operations
strf64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64
"2023-12-31 00:00:00"2.7180e9-3.9530e9-6.8400e81.9180e92.9e7-4.5200e83.66e85.25e8-1.5900e8-2.8640e9-2.8640e9-1.3300e8-5.8700e8-5.8700e8-3.9240e9-3.9530e92.9e71.7800e95.46e81.2340e9-6.8400e81.9180e9-4.6500e8-4.6500e81.7e7-1.0100e8null-1.0100e87.1e77.1e7-4.5200e83.1700e93.1700e96.9e71.48e82.05e8-6.1200e8-6.1200e82.77e82.77e82.77e8null3.0830e9
"2022-12-31 00:00:00"2.0310e9-2.5660e9-8.0400e89.83e80.0-3.3200e85.25e81.4210e9-8.9600e8-2.9620e9-2.9620e9-7.2e7-3.2100e8-3.2100e8-2.5660e9-2.5660e90.0-3e6-1.8200e81.79e8-8.0400e89.83e8-2.9700e8-2.9700e83.4e70.0null0.01e61e6-3.3200e82.3630e92.3630e9-5.4200e8-2.0700e81.92e82.8e82.8e82.82e82.82e82.82e8null2.3580e9
"2021-12-31 00:00:00"9.94e80.0-2.1740e91.7930e92e6-1.8300e81.4210e98.94e85.27e8-4.6300e8-4.6300e8-2.3400e80.00.02e60.02e6-2.3100e81.5e8-3.8100e8-2.1740e91.7930e9-1.8700e8-1.8700e8-1.6e70.0null0.01.2e71.2e7-1.8300e81.1770e91.1770e91.1e8-3.9200e81.82e8-2.8100e8-2.8100e82.95e82.95e82.95e81.64e81.0990e9
"2020-12-31 00:00:00"1.5040e9-1.5000e8-1.8870e93.5610e90.0-1.3500e88.94e82.53e86.41e8-1.0330e9-1.0330e9-1.1100e8-1.5600e8-1.5600e8-1.5000e8-1.5000e80.0-6.1600e8-2.2900e91.6740e9-1.8870e93.5610e93.5e73.5e7-9e72.6e82.6e8null2.6e82.6e8-1.3500e81.6390e91.6390e9-2.8e71.7300e92.01e8-4.7800e8-4.7800e84.78e84.78e84.78e83e6-2.6700e8
"2019-12-31 00:00:00"nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull3.95e8nullnullnullnullnullnullnullnullnullnullnullnullnullnull-1.4700e8null
FinancialStatements(ticker=MAR)

Income Statement

import polars as pl

fs.income_statement.with_columns(pl.col('*').forge_income_statement.gross_profit_margin(revenue_column='Total Revenue',cogs_column='Cost Of Revenue'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (5, 50)
dateTax Effect Of Unusual ItemsTax Rate For CalcsNormalized EBITDATotal Unusual ItemsTotal Unusual Items Excluding GoodwillNet Income From Continuing Operation Net Minority InterestReconciled DepreciationReconciled Cost Of RevenueEBITDAEBITNet Interest IncomeInterest ExpenseInterest IncomeNormalized IncomeNet Income From Continuing And Discontinued OperationTotal ExpensesTotal Operating Income As ReportedDiluted Average SharesBasic Average SharesDiluted EPSBasic EPSDiluted NI Availto Com StockholdersNet Income Common StockholdersNet IncomeNet Income Including Noncontrolling InterestsNet Income Continuous OperationsTax ProvisionPretax IncomeOther Income ExpenseOther Non Operating Income ExpensesSpecial Income ChargesOther Special ChargesRestructuring And Mergern AcquisitionEarnings From Equity InterestNet Non Operating Interest Income ExpenseInterest Expense Non OperatingInterest Income Non OperatingOperating IncomeOperating ExpenseDepreciation Amortization Depletion Income StatementDepreciation And Amortization In Income StatementSelling General And AdministrationGeneral And Administrative ExpenseOther Gand AGross ProfitCost Of RevenueTotal RevenueOperating Revenuegross_profit_margin
strf64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64
"2023-12-31 00:00:00"-5.22e60.0874.2800e9-6e7-6e73.0830e92.77e81.8501e104.2200e93.9430e9-5.3500e85.65e83e73.1378e93.0830e91.9789e103.8640e93.029e83.015e810.1810.233.0830e93.0830e93.0830e93.0830e93.0830e92.95e83.3780e9-1.1e74e7-6e7null6e79e6-5.3500e85.65e83e73.9240e91.2000e91.89e81.89e81.0110e91.0110e91.0110e95.1240e91.8589e102.3713e106.3880e90.216084
"2022-12-31 00:00:00"-2.916e60.2433.8110e9-1.2e7-1.2e72.3580e92.82e81.6126e103.7990e93.5170e9-3.7700e84.03e82.6e72.3671e92.3580e91.7299e103.4620e93.258e83.244e87.247.272.3580e92.3580e92.3580e92.3580e92.3580e97.56e83.1140e91.7e71.1e7-1.2e7null1.2e71.8e7-3.7700e84.03e82.6e73.4740e91.0840e91.93e81.93e88.91e88.91e88.91e84.5580e91.6215e102.0773e105.4450e90.219419
"2021-12-31 00:00:00"-1.1696e70.0682.0670e9-1.7200e8-1.7200e81.0990e92.95e81.0981e101.8950e91.6000e9-3.9200e84.2e82.8e71.2593e91.0990e91.2099e101.7500e93.293e83.272e83.343.361.0990e91.0990e91.0990e91.0990e91.0990e98.1e71.1800e9-1.8600e81e7-1.7200e81.64e88e6-2.4e7-3.9200e84.2e82.8e71.7580e91.0430e92.2e82.2e88.23e88.23e88.23e82.8010e91.1056e101.3857e103.4900e90.202136
"2020-12-31 00:00:00"-7.209e70.277.24e8-2.6700e8-2.6700e8-2.6700e84.78e88.9800e94.57e8-2.1e7-4.1800e84.45e82.7e7-7.209e7-2.6700e81.0220e108.4e73.258e83.258e8-0.82-0.82-2.6700e8-2.6700e8-2.6700e8-2.6700e8-2.6700e8-1.9900e8-4.6600e8-3.9900e89e6-2.6700e8null2.67e8-1.4100e8-4.1800e84.45e82.7e73.51e81.1080e93.46e83.46e87.62e87.62e87.62e81.4590e99.1120e91.0571e102.1190e90.138019
"2019-12-31 00:00:00"nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull-1.5400e8nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
fs.income_statement.with_columns(pl.col('*').forge_income_statement.net_profit_margin(revenue_column='Total Revenue',cogs_column='Cost Of Revenue',expenses_column='Total Expenses'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (5, 50)
dateTax Effect Of Unusual ItemsTax Rate For CalcsNormalized EBITDATotal Unusual ItemsTotal Unusual Items Excluding GoodwillNet Income From Continuing Operation Net Minority InterestReconciled DepreciationReconciled Cost Of RevenueEBITDAEBITNet Interest IncomeInterest ExpenseInterest IncomeNormalized IncomeNet Income From Continuing And Discontinued OperationTotal ExpensesTotal Operating Income As ReportedDiluted Average SharesBasic Average SharesDiluted EPSBasic EPSDiluted NI Availto Com StockholdersNet Income Common StockholdersNet IncomeNet Income Including Noncontrolling InterestsNet Income Continuous OperationsTax ProvisionPretax IncomeOther Income ExpenseOther Non Operating Income ExpensesSpecial Income ChargesOther Special ChargesRestructuring And Mergern AcquisitionEarnings From Equity InterestNet Non Operating Interest Income ExpenseInterest Expense Non OperatingInterest Income Non OperatingOperating IncomeOperating ExpenseDepreciation Amortization Depletion Income StatementDepreciation And Amortization In Income StatementSelling General And AdministrationGeneral And Administrative ExpenseOther Gand AGross ProfitCost Of RevenueTotal RevenueOperating Revenuenet_profit_margin
strf64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64f64
"2023-12-31 00:00:00"-5.22e60.0874.2800e9-6e7-6e73.0830e92.77e81.8501e104.2200e93.9430e9-5.3500e85.65e83e73.1378e93.0830e91.9789e103.8640e93.029e83.015e810.1810.233.0830e93.0830e93.0830e93.0830e93.0830e92.95e83.3780e9-1.1e74e7-6e7null6e79e6-5.3500e85.65e83e73.9240e91.2000e91.89e81.89e81.0110e91.0110e91.0110e95.1240e91.8589e102.3713e106.3880e9-0.618437
"2022-12-31 00:00:00"-2.916e60.2433.8110e9-1.2e7-1.2e72.3580e92.82e81.6126e103.7990e93.5170e9-3.7700e84.03e82.6e72.3671e92.3580e91.7299e103.4620e93.258e83.244e87.247.272.3580e92.3580e92.3580e92.3580e92.3580e97.56e83.1140e91.7e71.1e7-1.2e7null1.2e71.8e7-3.7700e84.03e82.6e73.4740e91.0840e91.93e81.93e88.91e88.91e88.91e84.5580e91.6215e102.0773e105.4450e9-0.613344
"2021-12-31 00:00:00"-1.1696e70.0682.0670e9-1.7200e8-1.7200e81.0990e92.95e81.0981e101.8950e91.6000e9-3.9200e84.2e82.8e71.2593e91.0990e91.2099e101.7500e93.293e83.272e83.343.361.0990e91.0990e91.0990e91.0990e91.0990e98.1e71.1800e9-1.8600e81e7-1.7200e81.64e88e6-2.4e7-3.9200e84.2e82.8e71.7580e91.0430e92.2e82.2e88.23e88.23e88.23e82.8010e91.1056e101.3857e103.4900e9-0.670997
"2020-12-31 00:00:00"-7.209e70.277.24e8-2.6700e8-2.6700e8-2.6700e84.78e88.9800e94.57e8-2.1e7-4.1800e84.45e82.7e7-7.209e7-2.6700e81.0220e108.4e73.258e83.258e8-0.82-0.82-2.6700e8-2.6700e8-2.6700e8-2.6700e8-2.6700e8-1.9900e8-4.6600e8-3.9900e89e6-2.6700e8null2.67e8-1.4100e8-4.1800e84.45e82.7e73.51e81.1080e93.46e83.46e87.62e87.62e87.62e81.4590e99.1120e91.0571e102.1190e9-0.828777
"2019-12-31 00:00:00"nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull-1.5400e8nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull

Mortgage

The Mortgage module contains mortgage objects that you enable you to assess mortgage metrics. You need to define these objects prior to running calcuations.

from metric_forge.mortgage import *

mortgage = Mortgage(principal=390000,annual_interest_rate=5.75,start_date='2023-09-01',term_years=30,extra_principal_payment=200)
mortgage.calculate_monthly_payment()
2275.934140129842
mortgage.generate_amortization_schedule()
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (360, 6)
payment_numberpayment_datepaymentinterest_paymentprincipal_paymentprincipal_remaining
i64strf64f64f64f64
1"2023-10-01"2275.934141868.75407.18414389592.81586
2"2023-10-31"2275.934141866.798909409.135231389183.680629
3"2023-11-30"2275.934141864.83847411.09567388772.584959
4"2023-12-30"2275.934141862.868636413.065504388359.519455
5"2024-01-29"2275.934141860.889364415.044776387944.474679
356"2052-11-27"2275.9341453.7524352222.1817058995.717798
357"2052-12-27"2275.9341443.1044812232.8296596762.888139
358"2053-01-26"2275.9341432.4055062243.5286344519.359505
359"2053-02-25"2275.9341421.6552642254.2788762265.080629
360"2053-03-27"2275.9341410.8535112265.0806291.2655e-8
mortgage.calculate_principal_only_payment()
{'new_term_years': 24.502707600761994, 'time_saved_years': 5.497292399238006}
mortgage.refinance_assessment(RefinanceOption(new_loan_amount=340000,new_annual_interest_rate=5.25,new_term_years=30,associated_costs=5000))
{'Old Monthly Payment': 2275.934140129842,
 'New Monthly Payment': 1877.492587282451,
 'Monthly Savings': 398.441552847391,
 'Break-Even Point (months)': 12.548891962367875,
 'Total Savings (over the loan term)': 138438.95902506076,
 'Should Refinance': True}

Web Traffic

from metric_forge.web_traffic import *
import polars as pl

data = pl.read_csv('datasets/web_traffic.csv')
data
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (4, 8)
total_durationtotal_sessionssingle_page_sessionsnum_clicksnum_impressionstotal_costexitstotal_page_views
i64i64i64i64i64i64i64i64
1200102100100050550
1500153150150075770
6021000220
2500255200200010010100

Average Session Duration

data.with_columns(pl.col('*').forge_web_traffic.average_session_duration(total_duration_col='total_duration', total_sessions_col='total_sessions'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (4, 9)
total_durationtotal_sessionssingle_page_sessionsnum_clicksnum_impressionstotal_costexitstotal_page_viewsaverage_session_duration
i64i64i64i64i64i64i64i64f64
1200102100100050550120.0
1500153150150075770100.0
602100022030.0
2500255200200010010100100.0

Bounce Rate

data.with_columns(pl.col('*').forge_web_traffic.bounce_rate(single_page_sessions_col='single_page_sessions', total_sessions_col='total_sessions'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (4, 9)
total_durationtotal_sessionssingle_page_sessionsnum_clicksnum_impressionstotal_costexitstotal_page_viewsbounce_rate
i64i64i64i64i64i64i64i64f64
120010210010005055020.0
150015315015007577020.0
602100022050.0
250025520020001001010020.0

Click Through Rate

data.with_columns(pl.col('*').forge_web_traffic.click_through_rate(num_clicks_col='num_clicks', num_impressions_col='num_impressions'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (4, 9)
total_durationtotal_sessionssingle_page_sessionsnum_clicksnum_impressionstotal_costexitstotal_page_viewsclick_through_rate
i64i64i64i64i64i64i64i64f64
120010210010005055010.0
150015315015007577010.0
6021000220NaN
250025520020001001010010.0

Cost Per Click

data.with_columns(pl.col('*').forge_web_traffic.cost_per_click(total_cost_col='total_cost',num_clicks_col='num_clicks'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (4, 9)
total_durationtotal_sessionssingle_page_sessionsnum_clicksnum_impressionstotal_costexitstotal_page_viewscost_per_click
i64i64i64i64i64i64i64i64f64
12001021001000505500.5
15001531501500757700.5
60210002200.0
25002552002000100101000.5

Exit Rate

data.with_columns(pl.col('*').forge_web_traffic.exit_rate(exits_col='exits',total_page_views_col='total_page_views'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (4, 9)
total_durationtotal_sessionssingle_page_sessionsnum_clicksnum_impressionstotal_costexitstotal_page_viewsexit_rate
i64i64i64i64i64i64i64i64f64
120010210010005055010.0
150015315015007577010.0
602100022010.0
250025520020001001010010.0

Pages Per Session

data.with_columns(pl.col('*').forge_web_traffic.pages_per_session(total_page_views_col='total_page_views',total_sessions_col='total_sessions'))
<style> .dataframe > thead > tr, .dataframe > tbody > tr { text-align: right; white-space: pre-wrap; } </style> shape: (4, 9)
total_durationtotal_sessionssingle_page_sessionsnum_clicksnum_impressionstotal_costexitstotal_page_viewspages_per_session
i64i64i64i64i64i64i64i64f64
12001021001000505505.0
15001531501500757704.666667
602100022010.0
25002552002000100101004.0


          

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metric_forge-0.3.0.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

metric_forge-0.3.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file metric_forge-0.3.0.tar.gz.

File metadata

  • Download URL: metric_forge-0.3.0.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for metric_forge-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d3aa13933d9c5d0d3c2a130b4e0cb837c7ec216875c353282386a01adf689425
MD5 77b38da57f82dd07f2ba3ad7d90f3b16
BLAKE2b-256 59e8ed4312cbd542eb4e161a958625b83f01e2b8f8f6d5f5f47938b812e673e1

See more details on using hashes here.

File details

Details for the file metric_forge-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: metric_forge-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for metric_forge-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f0236243ddcff0eaffac6992bd6dc451a08433ca22961049425eb723558864c
MD5 fe91c5125d5b38db71da57bbf19e7f68
BLAKE2b-256 d44fd50a17e023d460a15a8828bae62815547bdb4969789364cf7297408d2996

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page