diff --git a/docs/index.html b/docs/index.html
deleted file mode 100644
index a2e5861..0000000
--- a/docs/index.html
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
- Welcome to Metric Forge's documentation! — Metric Forge 0.3.0 documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Welcome to Metric Forge's documentation!
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 3420640..19873d1 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -36,7 +36,7 @@
project = 'Metric Forge'
copyright = '2024, Jayden Rasband'
author = 'Jayden Rasband'
-release = '0.3.0'
+release = '0.5.0'
# -- General configuration ---------------------------------------------------
diff --git a/metric_forge/human_capital/polars_ext.py b/metric_forge/human_capital/polars_ext.py
index 3cc496e..b1ca5ef 100644
--- a/metric_forge/human_capital/polars_ext.py
+++ b/metric_forge/human_capital/polars_ext.py
@@ -7,24 +7,84 @@ def __init__(self, expr: pl.Expr):
# Employee Turnover Rate
def employee_turnover_rate(self, employees_left_column: str, total_employees_column: str) -> pl.Expr:
+ '''
+ Calculates the employee turnover rate by dividing the number of employees who have left by the total number of employees.
+
+ Parameters
+ ----------
+ employees_left_column : str
+ The column name representing the number of employees who have left during a given period.
+ total_employees_column : str
+ The column name representing the total number of employees during the same period.
+
+ Returns
+ -------
+ pl.Expr
+ An expression representing the employee turnover rate, set to 0 if the total number of employees is zero.
+ '''
employees_left_expr = pl.col(employees_left_column)
total_employees_expr = pl.col(total_employees_column)
return pl.when(total_employees_expr == 0).then(0.0).otherwise(employees_left_expr / total_employees_expr).alias('employee_turnover_rate')
# Sales per Employee
def sales_per_employee(self, sales_column: str, total_employees_column: str) -> pl.Expr:
+ '''
+ Calculates the sales per employee by dividing total sales by the number of employees.
+
+ Parameters
+ ----------
+ sales_column : str
+ The column name representing the total sales over a given time period.
+ total_employees_column : str
+ The column name representing the total number of employees during the same period.
+
+ Returns
+ -------
+ pl.Expr
+ An expression representing sales per employee, set to 0 if the total number of employees is zero.
+ '''
sales_expr = pl.col(sales_column)
total_employees_expr = pl.col(total_employees_column)
return pl.when(total_employees_expr == 0).then(0.0).otherwise(sales_expr / total_employees_expr).alias('sales_per_employee')
# Absenteeism Rate
def absenteeism_rate(self, absent_days_column: str, total_workdays_column: str) -> pl.Expr:
+ '''
+ Calculates the absenteeism rate by dividing the number of absent days by the total number of workdays.
+
+ Parameters
+ ----------
+ absent_days_column : str
+ The column name representing the number of days employees were absent.
+ total_workdays_column : str
+ The column name representing the total number of workdays in a given period.
+
+ Returns
+ -------
+ pl.Expr
+ An expression representing the absenteeism rate, set to 0 if the total number of workdays is zero.
+ '''
absent_days_expr = pl.col(absent_days_column)
total_workdays_expr = pl.col(total_workdays_column)
return pl.when(total_workdays_expr == 0).then(0.0).otherwise(absent_days_expr / total_workdays_expr).alias('absenteeism_rate')
# Average Tenure of Employees
def average_tenure(self, total_tenure_column: str, total_employees_column: str) -> pl.Expr:
- total_tenure_expr = pl.col(total_tenure_column) # Assumes total tenure in years or months
+ '''
+ Calculates the average tenure of employees by dividing the total tenure by the total number of employees.
+
+ Parameters
+ ----------
+ total_tenure_column : str
+ The column name representing the total tenure of employees, typically in years or months.
+ total_employees_column : str
+ The column name representing the total number of employees.
+
+ Returns
+ -------
+ pl.Expr
+ An expression representing the average tenure of employees, set to 0 if the total number of employees is zero.
+ '''
+ total_tenure_expr = pl.col(total_tenure_column)
total_employees_expr = pl.col(total_employees_column)
return pl.when(total_employees_expr == 0).then(0.0).otherwise(total_tenure_expr / total_employees_expr).alias('average_tenure')
diff --git a/notebooks/ecommerce.ipynb b/notebooks/ecommerce.ipynb
new file mode 100644
index 0000000..cfd5a83
--- /dev/null
+++ b/notebooks/ecommerce.ipynb
@@ -0,0 +1,400 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Ecommerce\n",
+ "You can use Ecommerce Metrics in two different ways:\n",
+ "* With Polars\n",
+ "* As a Single Value Function (SVF)\n",
+ "\n",
+ "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. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (5, 15) month total_revenue number_of_orders cost_of_acquisition new_customers carts_created completed_purchases revenue_from_ads advertising_spend num_conversions num_visitors revenue_per_customer average_customer_lifetime num_customers_lost total_customers_beginning str f64 i64 f64 i64 i64 i64 f64 f64 i64 i64 f64 f64 i64 i64 "2023-01" 87454.011885 991 22958.350559 406 1969 1425 81339.957696 5390.910169 300 13154 202.427329 3.159364 239 3306 "2023-02" 145071.430641 913 18736.874206 234 1506 1421 76875.083402 15585.037018 427 14762 116.173436 1.812245 124 4680 "2023-03" 123199.394181 1305 28355.586842 120 1497 965 116505.482191 14872.037954 367 10056 384.265156 4.771414 177 4675 "2023-04" 109865.84842 885 14184.81582 428 1963 1102 106008.046381 12337.204368 132 19948 144.356328 3.395462 299 2972 "2023-05" 65601.864044 691 18764.339456 266 1009 801 97258.809912 5351.995568 147 13110 275.734601 3.77914 296 3768
"
+ ],
+ "text/plain": [
+ "shape: (5, 15)\n",
+ "┌─────────┬──────────────┬──────────────┬──────────────┬───┬─────────────┬─────────────┬─────────────┬─────────────┐\n",
+ "│ month ┆ total_revenu ┆ number_of_or ┆ cost_of_acqu ┆ … ┆ revenue_per ┆ average_cus ┆ num_custome ┆ total_custo │\n",
+ "│ --- ┆ e ┆ ders ┆ isition ┆ ┆ _customer ┆ tomer_lifet ┆ rs_lost ┆ mers_beginn │\n",
+ "│ str ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ ime ┆ --- ┆ ing │\n",
+ "│ ┆ f64 ┆ i64 ┆ f64 ┆ ┆ f64 ┆ --- ┆ i64 ┆ --- │\n",
+ "│ ┆ ┆ ┆ ┆ ┆ ┆ f64 ┆ ┆ i64 │\n",
+ "╞═════════╪══════════════╪══════════════╪══════════════╪═══╪═════════════╪═════════════╪═════════════╪═════════════╡\n",
+ "│ 2023-01 ┆ 87454.011885 ┆ 991 ┆ 22958.350559 ┆ … ┆ 202.427329 ┆ 3.159364 ┆ 239 ┆ 3306 │\n",
+ "│ 2023-02 ┆ 145071.43064 ┆ 913 ┆ 18736.874206 ┆ … ┆ 116.173436 ┆ 1.812245 ┆ 124 ┆ 4680 │\n",
+ "│ ┆ 1 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2023-03 ┆ 123199.39418 ┆ 1305 ┆ 28355.586842 ┆ … ┆ 384.265156 ┆ 4.771414 ┆ 177 ┆ 4675 │\n",
+ "│ ┆ 1 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2023-04 ┆ 109865.84842 ┆ 885 ┆ 14184.81582 ┆ … ┆ 144.356328 ┆ 3.395462 ┆ 299 ┆ 2972 │\n",
+ "│ 2023-05 ┆ 65601.864044 ┆ 691 ┆ 18764.339456 ┆ … ┆ 275.734601 ┆ 3.77914 ┆ 296 ┆ 3768 │\n",
+ "└─────────┴──────────────┴──────────────┴──────────────┴───┴─────────────┴─────────────┴─────────────┴─────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "from metric_forge.ecommerce import * \n",
+ "import polars as pl\n",
+ "data = pl.read_csv('datasets/ecommerce_metrics.csv')\n",
+ "data.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Customer Acquisition Cost"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (12, 3) cost_of_acquisition new_customers customer_acquisition_cost f64 i64 f64 22958.350559 406 56.547661 18736.874206 234 80.072112 28355.586842 120 236.296557 14184.81582 428 33.142093 18764.339456 266 70.54263 … … … 33555.278842 188 178.485526 15990.213465 415 38.530635 25427.033152 113 225.017992 27772.437066 341 81.444097 11393.512382 364 31.300858
"
+ ],
+ "text/plain": [
+ "shape: (12, 3)\n",
+ "┌─────────────────────┬───────────────┬───────────────────────────┐\n",
+ "│ cost_of_acquisition ┆ new_customers ┆ customer_acquisition_cost │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ f64 ┆ i64 ┆ f64 │\n",
+ "╞═════════════════════╪═══════════════╪═══════════════════════════╡\n",
+ "│ 22958.350559 ┆ 406 ┆ 56.547661 │\n",
+ "│ 18736.874206 ┆ 234 ┆ 80.072112 │\n",
+ "│ 28355.586842 ┆ 120 ┆ 236.296557 │\n",
+ "│ 14184.81582 ┆ 428 ┆ 33.142093 │\n",
+ "│ 18764.339456 ┆ 266 ┆ 70.54263 │\n",
+ "│ … ┆ … ┆ … │\n",
+ "│ 33555.278842 ┆ 188 ┆ 178.485526 │\n",
+ "│ 15990.213465 ┆ 415 ┆ 38.530635 │\n",
+ "│ 25427.033152 ┆ 113 ┆ 225.017992 │\n",
+ "│ 27772.437066 ┆ 341 ┆ 81.444097 │\n",
+ "│ 11393.512382 ┆ 364 ┆ 31.300858 │\n",
+ "└─────────────────────┴───────────────┴───────────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('cost_of_acquisition'),\n",
+ " pl.col('new_customers'),\n",
+ " pl.col('*').forge_ecommerce.customer_acquisition_cost('cost_of_acquisition', 'new_customers'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Average Order Value"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (12, 3) total_revenue new_customers average_order_value f64 i64 f64 87454.011885 406 88.248246 145071.430641 234 158.895324 123199.394181 120 94.405666 109865.84842 428 124.142202 65601.864044 266 94.937575 … … … 136617.614577 188 206.996386 110111.501174 415 114.819084 120807.25778 113 148.594413 52058.44943 341 99.920248 146990.985216 364 195.466736
"
+ ],
+ "text/plain": [
+ "shape: (12, 3)\n",
+ "┌───────────────┬───────────────┬─────────────────────┐\n",
+ "│ total_revenue ┆ new_customers ┆ average_order_value │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ f64 ┆ i64 ┆ f64 │\n",
+ "╞═══════════════╪═══════════════╪═════════════════════╡\n",
+ "│ 87454.011885 ┆ 406 ┆ 88.248246 │\n",
+ "│ 145071.430641 ┆ 234 ┆ 158.895324 │\n",
+ "│ 123199.394181 ┆ 120 ┆ 94.405666 │\n",
+ "│ 109865.84842 ┆ 428 ┆ 124.142202 │\n",
+ "│ 65601.864044 ┆ 266 ┆ 94.937575 │\n",
+ "│ … ┆ … ┆ … │\n",
+ "│ 136617.614577 ┆ 188 ┆ 206.996386 │\n",
+ "│ 110111.501174 ┆ 415 ┆ 114.819084 │\n",
+ "│ 120807.25778 ┆ 113 ┆ 148.594413 │\n",
+ "│ 52058.44943 ┆ 341 ┆ 99.920248 │\n",
+ "│ 146990.985216 ┆ 364 ┆ 195.466736 │\n",
+ "└───────────────┴───────────────┴─────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('total_revenue'),\n",
+ " pl.col('new_customers'),\n",
+ " pl.col('*').forge_ecommerce.average_order_value('total_revenue', 'number_of_orders'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Cart Abandonment Rate"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (12, 3) carts_created completed_purchases cart_abandonment_rate i64 i64 f64 1969 1425 27.628238 1506 1421 5.64409 1497 965 35.537742 1963 1102 43.861437 1009 801 20.61447 … … … 1108 601 45.758123 1975 1395 29.367089 800 669 16.375 2005 1215 39.401496 1704 855 49.823944
"
+ ],
+ "text/plain": [
+ "shape: (12, 3)\n",
+ "┌───────────────┬─────────────────────┬───────────────────────┐\n",
+ "│ carts_created ┆ completed_purchases ┆ cart_abandonment_rate │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ f64 │\n",
+ "╞═══════════════╪═════════════════════╪═══════════════════════╡\n",
+ "│ 1969 ┆ 1425 ┆ 27.628238 │\n",
+ "│ 1506 ┆ 1421 ┆ 5.64409 │\n",
+ "│ 1497 ┆ 965 ┆ 35.537742 │\n",
+ "│ 1963 ┆ 1102 ┆ 43.861437 │\n",
+ "│ 1009 ┆ 801 ┆ 20.61447 │\n",
+ "│ … ┆ … ┆ … │\n",
+ "│ 1108 ┆ 601 ┆ 45.758123 │\n",
+ "│ 1975 ┆ 1395 ┆ 29.367089 │\n",
+ "│ 800 ┆ 669 ┆ 16.375 │\n",
+ "│ 2005 ┆ 1215 ┆ 39.401496 │\n",
+ "│ 1704 ┆ 855 ┆ 49.823944 │\n",
+ "└───────────────┴─────────────────────┴───────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('carts_created'),\n",
+ " pl.col('completed_purchases'),\n",
+ " pl.col('*').forge_ecommerce.cart_abandonment_rate('carts_created', 'completed_purchases'))\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Return on Advertising Spend"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (12, 3) revenue_from_ads advertising_spend return_on_advertising_spend f64 f64 f64 81339.957696 5390.910169 15.088353 76875.083402 15585.037018 4.932621 116505.482191 14872.037954 7.833861 106008.046381 12337.204368 8.59255 97258.809912 5351.995568 18.172438 … … … 116872.977654 24754.388513 4.721303 84633.082292 20148.99937 4.200362 54839.926382 28157.521963 1.947612 56664.615513 21276.925638 2.663196 44874.024516 27873.991889 1.609889
"
+ ],
+ "text/plain": [
+ "shape: (12, 3)\n",
+ "┌──────────────────┬───────────────────┬─────────────────────────────┐\n",
+ "│ revenue_from_ads ┆ advertising_spend ┆ return_on_advertising_spend │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ f64 ┆ f64 ┆ f64 │\n",
+ "╞══════════════════╪═══════════════════╪═════════════════════════════╡\n",
+ "│ 81339.957696 ┆ 5390.910169 ┆ 15.088353 │\n",
+ "│ 76875.083402 ┆ 15585.037018 ┆ 4.932621 │\n",
+ "│ 116505.482191 ┆ 14872.037954 ┆ 7.833861 │\n",
+ "│ 106008.046381 ┆ 12337.204368 ┆ 8.59255 │\n",
+ "│ 97258.809912 ┆ 5351.995568 ┆ 18.172438 │\n",
+ "│ … ┆ … ┆ … │\n",
+ "│ 116872.977654 ┆ 24754.388513 ┆ 4.721303 │\n",
+ "│ 84633.082292 ┆ 20148.99937 ┆ 4.200362 │\n",
+ "│ 54839.926382 ┆ 28157.521963 ┆ 1.947612 │\n",
+ "│ 56664.615513 ┆ 21276.925638 ┆ 2.663196 │\n",
+ "│ 44874.024516 ┆ 27873.991889 ┆ 1.609889 │\n",
+ "└──────────────────┴───────────────────┴─────────────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('revenue_from_ads'),\n",
+ " pl.col('advertising_spend'),\n",
+ " pl.col('*').forge_ecommerce.return_on_advertising_spend('revenue_from_ads', 'advertising_spend'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Conversion Rate"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (12, 3) num_conversions num_visitors conversion_rate i64 i64 f64 300 13154 2.280675 427 14762 2.892562 367 10056 3.649562 132 19948 0.66172 147 13110 1.121281 … … … 392 8840 4.434389 198 6028 3.284672 271 12385 2.188131 459 5502 8.342421 313 11910 2.628044
"
+ ],
+ "text/plain": [
+ "shape: (12, 3)\n",
+ "┌─────────────────┬──────────────┬─────────────────┐\n",
+ "│ num_conversions ┆ num_visitors ┆ conversion_rate │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ f64 │\n",
+ "╞═════════════════╪══════════════╪═════════════════╡\n",
+ "│ 300 ┆ 13154 ┆ 2.280675 │\n",
+ "│ 427 ┆ 14762 ┆ 2.892562 │\n",
+ "│ 367 ┆ 10056 ┆ 3.649562 │\n",
+ "│ 132 ┆ 19948 ┆ 0.66172 │\n",
+ "│ 147 ┆ 13110 ┆ 1.121281 │\n",
+ "│ … ┆ … ┆ … │\n",
+ "│ 392 ┆ 8840 ┆ 4.434389 │\n",
+ "│ 198 ┆ 6028 ┆ 3.284672 │\n",
+ "│ 271 ┆ 12385 ┆ 2.188131 │\n",
+ "│ 459 ┆ 5502 ┆ 8.342421 │\n",
+ "│ 313 ┆ 11910 ┆ 2.628044 │\n",
+ "└─────────────────┴──────────────┴─────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('num_conversions'),\n",
+ " pl.col('num_visitors'),\n",
+ " pl.col('*').forge_ecommerce.conversion_rate('num_conversions', 'num_visitors'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Customer Lifetime Value"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (12, 3) revenue_per_customer average_customer_lifetime customer_lifetime_value f64 f64 f64 202.427329 3.159364 639.54169 116.173436 1.812245 210.534716 384.265156 4.771414 1833.488253 144.356328 3.395462 490.156408 275.734601 3.77914 1042.039585 … … … 290.148089 2.182535 633.258286 325.310229 1.421977 462.583676 378.206435 2.826138 1068.863683 155.732582 1.873762 291.805755 341.766952 2.66604 911.164293
"
+ ],
+ "text/plain": [
+ "shape: (12, 3)\n",
+ "┌──────────────────────┬───────────────────────────┬─────────────────────────┐\n",
+ "│ revenue_per_customer ┆ average_customer_lifetime ┆ customer_lifetime_value │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ f64 ┆ f64 ┆ f64 │\n",
+ "╞══════════════════════╪═══════════════════════════╪═════════════════════════╡\n",
+ "│ 202.427329 ┆ 3.159364 ┆ 639.54169 │\n",
+ "│ 116.173436 ┆ 1.812245 ┆ 210.534716 │\n",
+ "│ 384.265156 ┆ 4.771414 ┆ 1833.488253 │\n",
+ "│ 144.356328 ┆ 3.395462 ┆ 490.156408 │\n",
+ "│ 275.734601 ┆ 3.77914 ┆ 1042.039585 │\n",
+ "│ … ┆ … ┆ … │\n",
+ "│ 290.148089 ┆ 2.182535 ┆ 633.258286 │\n",
+ "│ 325.310229 ┆ 1.421977 ┆ 462.583676 │\n",
+ "│ 378.206435 ┆ 2.826138 ┆ 1068.863683 │\n",
+ "│ 155.732582 ┆ 1.873762 ┆ 291.805755 │\n",
+ "│ 341.766952 ┆ 2.66604 ┆ 911.164293 │\n",
+ "└──────────────────────┴───────────────────────────┴─────────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('revenue_per_customer'),\n",
+ " pl.col('average_customer_lifetime'),\n",
+ " pl.col('*').forge_ecommerce.customer_lifetime_value(revenue_per_customer_column='revenue_per_customer',average_customer_lifetime_column='average_customer_lifetime',method='basic'))"
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/finance.ipynb b/notebooks/finance.ipynb
new file mode 100644
index 0000000..eb86b05
--- /dev/null
+++ b/notebooks/finance.ipynb
@@ -0,0 +1,300 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Finance\n",
+ "\n",
+ "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. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Financial Statement Objects"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "Income Statement "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (5, 49) date Tax Effect Of Unusual Items Tax Rate For Calcs Normalized EBITDA Total Unusual Items Total Unusual Items Excluding Goodwill Net Income From Continuing Operation Net Minority Interest Reconciled Depreciation Reconciled Cost Of Revenue EBITDA EBIT Net Interest Income Interest Expense Interest Income Normalized Income Net Income From Continuing And Discontinued Operation Total Expenses Total Operating Income As Reported Diluted Average Shares Basic Average Shares Diluted EPS Basic EPS Diluted NI Availto Com Stockholders Net Income Common Stockholders Net Income Net Income Including Noncontrolling Interests Net Income Continuous Operations Tax Provision Pretax Income Other Income Expense Other Non Operating Income Expenses Special Income Charges Other Special Charges Restructuring And Mergern Acquisition Earnings From Equity Interest Net Non Operating Interest Income Expense Interest Expense Non Operating Interest Income Non Operating Operating Income Operating Expense Depreciation Amortization Depletion Income Statement Depreciation And Amortization In Income Statement Selling General And Administration General And Administrative Expense Other Gand A Gross Profit Cost Of Revenue Total Revenue Operating Revenue str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" -5.22e6 0.087 4.2800e9 -6e7 -6e7 3.0830e9 2.77e8 1.8501e10 4.2200e9 3.9430e9 -5.3500e8 5.65e8 3e7 3.1378e9 3.0830e9 1.9789e10 3.8640e9 3.029e8 3.015e8 10.18 10.23 3.0830e9 3.0830e9 3.0830e9 3.0830e9 3.0830e9 2.95e8 3.3780e9 -1.1e7 4e7 -6e7 null 6e7 9e6 -5.3500e8 5.65e8 3e7 3.9240e9 1.2000e9 1.89e8 1.89e8 1.0110e9 1.0110e9 1.0110e9 5.1240e9 1.8589e10 2.3713e10 6.3880e9 "2022-12-31 00:00:00" -2.916e6 0.243 3.8110e9 -1.2e7 -1.2e7 2.3580e9 2.82e8 1.6126e10 3.7990e9 3.5170e9 -3.7700e8 4.03e8 2.6e7 2.3671e9 2.3580e9 1.7299e10 3.4620e9 3.258e8 3.244e8 7.24 7.27 2.3580e9 2.3580e9 2.3580e9 2.3580e9 2.3580e9 7.56e8 3.1140e9 1.7e7 1.1e7 -1.2e7 null 1.2e7 1.8e7 -3.7700e8 4.03e8 2.6e7 3.4740e9 1.0840e9 1.93e8 1.93e8 8.91e8 8.91e8 8.91e8 4.5580e9 1.6215e10 2.0773e10 5.4450e9 "2021-12-31 00:00:00" -1.1696e7 0.068 2.0670e9 -1.7200e8 -1.7200e8 1.0990e9 2.95e8 1.0981e10 1.8950e9 1.6000e9 -3.9200e8 4.2e8 2.8e7 1.2593e9 1.0990e9 1.2099e10 1.7500e9 3.293e8 3.272e8 3.34 3.36 1.0990e9 1.0990e9 1.0990e9 1.0990e9 1.0990e9 8.1e7 1.1800e9 -1.8600e8 1e7 -1.7200e8 1.64e8 8e6 -2.4e7 -3.9200e8 4.2e8 2.8e7 1.7580e9 1.0430e9 2.2e8 2.2e8 8.23e8 8.23e8 8.23e8 2.8010e9 1.1056e10 1.3857e10 3.4900e9 "2020-12-31 00:00:00" -7.209e7 0.27 7.24e8 -2.6700e8 -2.6700e8 -2.6700e8 4.78e8 8.9800e9 4.57e8 -2.1e7 -4.1800e8 4.45e8 2.7e7 -7.209e7 -2.6700e8 1.0220e10 8.4e7 3.258e8 3.258e8 -0.82 -0.82 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -1.9900e8 -4.6600e8 -3.9900e8 9e6 -2.6700e8 null 2.67e8 -1.4100e8 -4.1800e8 4.45e8 2.7e7 3.51e8 1.1080e9 3.46e8 3.46e8 7.62e8 7.62e8 7.62e8 1.4590e9 9.1120e9 1.0571e10 2.1190e9 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null -1.5400e8 null null null null null null null null null null null null null null null null
"
+ ],
+ "text/plain": [
+ "shape: (5, 49)\n",
+ "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
+ "│ date ┆ Tax Effect ┆ Tax Rate ┆ Normalized ┆ … ┆ Gross ┆ Cost Of ┆ Total ┆ Operating │\n",
+ "│ --- ┆ Of Unusual ┆ For Calcs ┆ EBITDA ┆ ┆ Profit ┆ Revenue ┆ Revenue ┆ Revenue │\n",
+ "│ str ┆ Items ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n",
+ "│ ┆ --- ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
+ "│ ┆ f64 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
+ "│ 2023-12-31 ┆ -5.22e6 ┆ 0.087 ┆ 4.2800e9 ┆ … ┆ 5.1240e9 ┆ 1.8589e10 ┆ 2.3713e10 ┆ 6.3880e9 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2022-12-31 ┆ -2.916e6 ┆ 0.243 ┆ 3.8110e9 ┆ … ┆ 4.5580e9 ┆ 1.6215e10 ┆ 2.0773e10 ┆ 5.4450e9 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2021-12-31 ┆ -1.1696e7 ┆ 0.068 ┆ 2.0670e9 ┆ … ┆ 2.8010e9 ┆ 1.1056e10 ┆ 1.3857e10 ┆ 3.4900e9 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2020-12-31 ┆ -7.209e7 ┆ 0.27 ┆ 7.24e8 ┆ … ┆ 1.4590e9 ┆ 9.1120e9 ┆ 1.0571e10 ┆ 2.1190e9 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Balance Sheet "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (5, 69) date Ordinary Shares Number Share Issued Net Debt Total Debt Tangible Book Value Invested Capital Working Capital Net Tangible Assets Capital Lease Obligations Common Stock Equity Total Capitalization Total Equity Gross Minority Interest Stockholders Equity Gains Losses Not Affecting Retained Earnings Other Equity Adjustments Treasury Stock Retained Earnings Additional Paid In Capital Capital Stock Common Stock Total Liabilities Net Minority Interest Total Non Current Liabilities Net Minority Interest Other Non Current Liabilities Non Current Deferred Liabilities Non Current Deferred Revenue Non Current Deferred Taxes Liabilities Long Term Debt And Capital Lease Obligation Long Term Capital Lease Obligation Long Term Debt Current Liabilities Other Current Liabilities Current Debt And Capital Lease Obligation Current Debt Payables And Accrued Expenses Current Accrued Expenses Payables Accounts Payable Total Assets Total Non Current Assets Other Non Current Assets Non Current Deferred Assets Non Current Deferred Taxes Assets Non Current Note Receivables Investments And Advances Long Term Equity Investment Goodwill And Other Intangible Assets Other Intangible Assets Goodwill Net PPE Accumulated Depreciation Gross PPE Construction In Progress Other Properties Machinery Furniture Equipment Buildings And Improvements Land And Improvements Properties Current Assets Other Current Assets Assets Held For Sale Current Prepaid Assets Receivables Accounts Receivable Allowance For Doubtful Accounts Receivable Gross Accounts Receivable Cash Cash Equivalents And Short Term Investments Cash And Cash Equivalents Cash Financial str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" 2.90539975e8 2.90539975e8 1.1535e10 1.2760e10 -1.8758e10 1.1191e10 -4.4510e9 -1.8758e10 8.87e8 -6.8200e8 1.0638e10 -6.8200e8 -6.8200e8 -6.4700e8 -6.4700e8 2.0929e10 1.4838e10 6.0510e9 5e6 5e6 2.6356e10 1.8594e10 5.1600e9 1.2270e9 1.0180e9 2.09e8 1.2207e10 8.87e8 1.1320e10 7.7620e9 3.3280e9 5.53e8 5.53e8 3.8810e9 3.1430e9 7.38e8 7.38e8 2.5674e10 2.2363e10 6.58e8 6.73e8 6.73e8 1.38e8 3.08e8 3.08e8 1.8076e10 9.1900e9 8.8860e9 2.5100e9 -8.9000e8 3.4000e9 7.2e7 9.29e8 6.22e8 1.1080e9 6.69e8 0.0 3.3110e9 2.61e8 null null 2.7120e9 2.7120e9 -1.9700e8 2.9090e9 3.38e8 3.38e8 null "2022-12-31 00:00:00" 3.106e8 3.106e8 9.5570e9 1.1098e10 -1.7051e10 1.0632e10 -4.0260e9 -1.7051e10 1.0340e9 5.68e8 9.9480e9 5.68e8 5.68e8 -7.2900e8 -7.2900e8 1.7015e10 1.2342e10 5.9650e9 5e6 5e6 2.4247e10 1.6908e10 5.1220e9 1.3720e9 1.0590e9 3.13e8 1.0414e10 1.0340e9 9.3800e9 7.3390e9 3.3140e9 6.84e8 6.84e8 3.3410e9 2.5950e9 7.46e8 7.46e8 2.4815e10 2.1502e10 5.84e8 2.4e8 2.4e8 1.52e8 3.35e8 3.35e8 1.7619e10 8.7470e9 8.8720e9 2.5720e9 -8.7400e8 3.4460e9 3.6e7 9.87e8 6.49e8 1.0860e9 6.88e8 0.0 3.3130e9 2.35e8 null null 2.5710e9 2.5710e9 -1.9100e8 2.7620e9 5.07e8 5.07e8 null "2021-12-31 00:00:00" 3.273e8 3.273e8 8.7450e9 1.1236e10 -1.6585e10 1.1552e10 -2.7810e9 -1.6585e10 1.0980e9 1.4140e9 1.0747e10 1.4140e9 1.4140e9 -3.4200e8 -3.4200e8 1.4446e10 1.0305e10 5.8920e9 5e6 5e6 2.4139e10 1.7732e10 5.9510e9 1.3500e9 1.1810e9 1.69e8 1.0431e10 1.0980e9 9.3330e9 6.4070e9 2.5220e9 8.05e8 8.05e8 3.0800e9 2.3540e9 7.26e8 7.26e8 2.5553e10 2.1927e10 6.04e8 2.28e8 2.28e8 1.44e8 3.87e8 3.87e8 1.7999e10 8.9260e9 9.0730e9 2.5650e9 -8.5000e8 3.4150e9 1.37e8 1.0620e9 5.45e8 9.85e8 6.86e8 0.0 3.6260e9 2.51e8 null 2.51e8 1.9820e9 1.9820e9 -1.8700e8 2.1690e9 1.3930e9 1.3930e9 null "2020-12-31 00:00:00" 3.244e8 3.244e8 9.4990e9 1.1199e10 -1.7734e10 1.0806e10 -2.9270e9 -1.7734e10 8.23e8 4.3e8 9.6330e9 4.3e8 4.3e8 -1.3500e8 -1.3500e8 1.4497e10 9.2060e9 5.8510e9 5e6 5e6 2.4271e10 1.8519e10 6.8680e9 1.6250e9 1.5420e9 8.3e7 1.0026e10 8.23e8 9.2030e9 5.7520e9 1.7690e9 1.1730e9 1.1730e9 2.8100e9 2.2830e9 5.27e8 5.27e8 2.4701e10 2.1876e10 6.16e8 2.49e8 2.49e8 1.59e8 4.22e8 null 1.8164e10 8.9890e9 9.1750e9 2.2660e9 -8.8800e8 3.1540e9 2.9e7 7.52e8 6.4e8 1.0450e9 6.88e8 0.0 2.8250e9 1.8e8 8e6 1.8e8 1.7680e9 1.7680e9 null null 8.77e8 8.77e8 null "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null 2.55e8 2.52e8 null null null null null null 2.25e8
"
+ ],
+ "text/plain": [
+ "shape: (5, 69)\n",
+ "┌──────────────┬─────────────┬─────────────┬───────────┬───┬─────────────┬─────────────┬─────────────┬─────────────┐\n",
+ "│ date ┆ Ordinary ┆ Share ┆ Net Debt ┆ … ┆ Gross ┆ Cash Cash ┆ Cash And ┆ Cash │\n",
+ "│ --- ┆ Shares ┆ Issued ┆ --- ┆ ┆ Accounts ┆ Equivalents ┆ Cash ┆ Financial │\n",
+ "│ str ┆ Number ┆ --- ┆ f64 ┆ ┆ Receivable ┆ And Shor… ┆ Equivalents ┆ --- │\n",
+ "│ ┆ --- ┆ f64 ┆ ┆ ┆ --- ┆ --- ┆ --- ┆ f64 │\n",
+ "│ ┆ f64 ┆ ┆ ┆ ┆ f64 ┆ f64 ┆ f64 ┆ │\n",
+ "╞══════════════╪═════════════╪═════════════╪═══════════╪═══╪═════════════╪═════════════╪═════════════╪═════════════╡\n",
+ "│ 2023-12-31 ┆ 2.90539975e ┆ 2.90539975e ┆ 1.1535e10 ┆ … ┆ 2.9090e9 ┆ 3.38e8 ┆ 3.38e8 ┆ null │\n",
+ "│ 00:00:00 ┆ 8 ┆ 8 ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2022-12-31 ┆ 3.106e8 ┆ 3.106e8 ┆ 9.5570e9 ┆ … ┆ 2.7620e9 ┆ 5.07e8 ┆ 5.07e8 ┆ null │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2021-12-31 ┆ 3.273e8 ┆ 3.273e8 ┆ 8.7450e9 ┆ … ┆ 2.1690e9 ┆ 1.3930e9 ┆ 1.3930e9 ┆ null │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2020-12-31 ┆ 3.244e8 ┆ 3.244e8 ┆ 9.4990e9 ┆ … ┆ null ┆ 8.77e8 ┆ 8.77e8 ┆ null │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ 2.25e8 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "└──────────────┴─────────────┴─────────────┴───────────┴───┴─────────────┴─────────────┴─────────────┴─────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Cash Flow "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (5, 44) date Free Cash Flow Repurchase Of Capital Stock Repayment Of Debt Issuance Of Debt Issuance Of Capital Stock Capital Expenditure End Cash Position Beginning Cash Position Changes In Cash Financing Cash Flow Cash Flow From Continuing Financing Activities Net Other Financing Charges Cash Dividends Paid Common Stock Dividend Paid Net Common Stock Issuance Common Stock Payments Common Stock Issuance Net Issuance Payments Of Debt Net Short Term Debt Issuance Net Long Term Debt Issuance Long Term Debt Payments Long Term Debt Issuance Investing Cash Flow Cash Flow From Continuing Investing Activities Net Other Investing Changes Net Business Purchase And Sale Sale Of Business Purchase Of Business Net PPE Purchase And Sale Sale Of PPE Capital Expenditure Reported Operating Cash Flow Cash Flow From Continuing Operating Activities Change In Working Capital Other Non Cash Items Stock Based Compensation Deferred Tax Deferred Income Tax Depreciation Amortization Depletion Depreciation And Amortization Depreciation Operating Gains Losses Net Income From Continuing Operations str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" 2.7180e9 -3.9530e9 -6.8400e8 1.9180e9 2.9e7 -4.5200e8 3.66e8 5.25e8 -1.5900e8 -2.8640e9 -2.8640e9 -1.3300e8 -5.8700e8 -5.8700e8 -3.9240e9 -3.9530e9 2.9e7 1.7800e9 5.46e8 1.2340e9 -6.8400e8 1.9180e9 -4.6500e8 -4.6500e8 1.7e7 -1.0100e8 null -1.0100e8 7.1e7 7.1e7 -4.5200e8 3.1700e9 3.1700e9 6.9e7 1.48e8 2.05e8 -6.1200e8 -6.1200e8 2.77e8 2.77e8 2.77e8 null 3.0830e9 "2022-12-31 00:00:00" 2.0310e9 -2.5660e9 -8.0400e8 9.83e8 0.0 -3.3200e8 5.25e8 1.4210e9 -8.9600e8 -2.9620e9 -2.9620e9 -7.2e7 -3.2100e8 -3.2100e8 -2.5660e9 -2.5660e9 0.0 -3e6 -1.8200e8 1.79e8 -8.0400e8 9.83e8 -2.9700e8 -2.9700e8 3.4e7 0.0 null 0.0 1e6 1e6 -3.3200e8 2.3630e9 2.3630e9 -5.4200e8 -2.0700e8 1.92e8 2.8e8 2.8e8 2.82e8 2.82e8 2.82e8 null 2.3580e9 "2021-12-31 00:00:00" 9.94e8 0.0 -2.1740e9 1.7930e9 2e6 -1.8300e8 1.4210e9 8.94e8 5.27e8 -4.6300e8 -4.6300e8 -2.3400e8 0.0 0.0 2e6 0.0 2e6 -2.3100e8 1.5e8 -3.8100e8 -2.1740e9 1.7930e9 -1.8700e8 -1.8700e8 -1.6e7 0.0 null 0.0 1.2e7 1.2e7 -1.8300e8 1.1770e9 1.1770e9 1.1e8 -3.9200e8 1.82e8 -2.8100e8 -2.8100e8 2.95e8 2.95e8 2.95e8 1.64e8 1.0990e9 "2020-12-31 00:00:00" 1.5040e9 -1.5000e8 -1.8870e9 3.5610e9 0.0 -1.3500e8 8.94e8 2.53e8 6.41e8 -1.0330e9 -1.0330e9 -1.1100e8 -1.5600e8 -1.5600e8 -1.5000e8 -1.5000e8 0.0 -6.1600e8 -2.2900e9 1.6740e9 -1.8870e9 3.5610e9 3.5e7 3.5e7 -9e7 2.6e8 2.6e8 null 2.6e8 2.6e8 -1.3500e8 1.6390e9 1.6390e9 -2.8e7 1.7300e9 2.01e8 -4.7800e8 -4.7800e8 4.78e8 4.78e8 4.78e8 3e6 -2.6700e8 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null 3.95e8 null null null null null null null null null null null null null null -1.4700e8 null
"
+ ],
+ "text/plain": [
+ "shape: (5, 44)\n",
+ "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
+ "│ date ┆ Free Cash ┆ Repurchase ┆ Repayment ┆ … ┆ Depreciatio ┆ Depreciatio ┆ Operating ┆ Net Income │\n",
+ "│ --- ┆ Flow ┆ Of Capital ┆ Of Debt ┆ ┆ n And Amort ┆ n ┆ Gains ┆ From │\n",
+ "│ str ┆ --- ┆ Stock ┆ --- ┆ ┆ ization ┆ --- ┆ Losses ┆ Continuing │\n",
+ "│ ┆ f64 ┆ --- ┆ f64 ┆ ┆ --- ┆ f64 ┆ --- ┆ Ope… │\n",
+ "│ ┆ ┆ f64 ┆ ┆ ┆ f64 ┆ ┆ f64 ┆ --- │\n",
+ "│ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ f64 │\n",
+ "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
+ "│ 2023-12-31 ┆ 2.7180e9 ┆ -3.9530e9 ┆ -6.8400e8 ┆ … ┆ 2.77e8 ┆ 2.77e8 ┆ null ┆ 3.0830e9 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2022-12-31 ┆ 2.0310e9 ┆ -2.5660e9 ┆ -8.0400e8 ┆ … ┆ 2.82e8 ┆ 2.82e8 ┆ null ┆ 2.3580e9 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2021-12-31 ┆ 9.94e8 ┆ 0.0 ┆ -2.1740e9 ┆ … ┆ 2.95e8 ┆ 2.95e8 ┆ 1.64e8 ┆ 1.0990e9 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2020-12-31 ┆ 1.5040e9 ┆ -1.5000e8 ┆ -1.8870e9 ┆ … ┆ 4.78e8 ┆ 4.78e8 ┆ 3e6 ┆ -2.6700e8 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ -1.4700e8 ┆ null │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ "FinancialStatements(ticker=MAR)"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "from metric_forge import *\n",
+ "\n",
+ "fs = import_financials(ticker='MAR',engine='yfinance')\n",
+ "fs"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Income Statement"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (5, 50) date Tax Effect Of Unusual Items Tax Rate For Calcs Normalized EBITDA Total Unusual Items Total Unusual Items Excluding Goodwill Net Income From Continuing Operation Net Minority Interest Reconciled Depreciation Reconciled Cost Of Revenue EBITDA EBIT Net Interest Income Interest Expense Interest Income Normalized Income Net Income From Continuing And Discontinued Operation Total Expenses Total Operating Income As Reported Diluted Average Shares Basic Average Shares Diluted EPS Basic EPS Diluted NI Availto Com Stockholders Net Income Common Stockholders Net Income Net Income Including Noncontrolling Interests Net Income Continuous Operations Tax Provision Pretax Income Other Income Expense Other Non Operating Income Expenses Special Income Charges Other Special Charges Restructuring And Mergern Acquisition Earnings From Equity Interest Net Non Operating Interest Income Expense Interest Expense Non Operating Interest Income Non Operating Operating Income Operating Expense Depreciation Amortization Depletion Income Statement Depreciation And Amortization In Income Statement Selling General And Administration General And Administrative Expense Other Gand A Gross Profit Cost Of Revenue Total Revenue Operating Revenue gross_profit_margin str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" -5.22e6 0.087 4.2800e9 -6e7 -6e7 3.0830e9 2.77e8 1.8501e10 4.2200e9 3.9430e9 -5.3500e8 5.65e8 3e7 3.1378e9 3.0830e9 1.9789e10 3.8640e9 3.029e8 3.015e8 10.18 10.23 3.0830e9 3.0830e9 3.0830e9 3.0830e9 3.0830e9 2.95e8 3.3780e9 -1.1e7 4e7 -6e7 null 6e7 9e6 -5.3500e8 5.65e8 3e7 3.9240e9 1.2000e9 1.89e8 1.89e8 1.0110e9 1.0110e9 1.0110e9 5.1240e9 1.8589e10 2.3713e10 6.3880e9 0.216084 "2022-12-31 00:00:00" -2.916e6 0.243 3.8110e9 -1.2e7 -1.2e7 2.3580e9 2.82e8 1.6126e10 3.7990e9 3.5170e9 -3.7700e8 4.03e8 2.6e7 2.3671e9 2.3580e9 1.7299e10 3.4620e9 3.258e8 3.244e8 7.24 7.27 2.3580e9 2.3580e9 2.3580e9 2.3580e9 2.3580e9 7.56e8 3.1140e9 1.7e7 1.1e7 -1.2e7 null 1.2e7 1.8e7 -3.7700e8 4.03e8 2.6e7 3.4740e9 1.0840e9 1.93e8 1.93e8 8.91e8 8.91e8 8.91e8 4.5580e9 1.6215e10 2.0773e10 5.4450e9 0.219419 "2021-12-31 00:00:00" -1.1696e7 0.068 2.0670e9 -1.7200e8 -1.7200e8 1.0990e9 2.95e8 1.0981e10 1.8950e9 1.6000e9 -3.9200e8 4.2e8 2.8e7 1.2593e9 1.0990e9 1.2099e10 1.7500e9 3.293e8 3.272e8 3.34 3.36 1.0990e9 1.0990e9 1.0990e9 1.0990e9 1.0990e9 8.1e7 1.1800e9 -1.8600e8 1e7 -1.7200e8 1.64e8 8e6 -2.4e7 -3.9200e8 4.2e8 2.8e7 1.7580e9 1.0430e9 2.2e8 2.2e8 8.23e8 8.23e8 8.23e8 2.8010e9 1.1056e10 1.3857e10 3.4900e9 0.202136 "2020-12-31 00:00:00" -7.209e7 0.27 7.24e8 -2.6700e8 -2.6700e8 -2.6700e8 4.78e8 8.9800e9 4.57e8 -2.1e7 -4.1800e8 4.45e8 2.7e7 -7.209e7 -2.6700e8 1.0220e10 8.4e7 3.258e8 3.258e8 -0.82 -0.82 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -1.9900e8 -4.6600e8 -3.9900e8 9e6 -2.6700e8 null 2.67e8 -1.4100e8 -4.1800e8 4.45e8 2.7e7 3.51e8 1.1080e9 3.46e8 3.46e8 7.62e8 7.62e8 7.62e8 1.4590e9 9.1120e9 1.0571e10 2.1190e9 0.138019 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null -1.5400e8 null null null null null null null null null null null null null null null null null
"
+ ],
+ "text/plain": [
+ "shape: (5, 50)\n",
+ "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
+ "│ date ┆ Tax Effect ┆ Tax Rate ┆ Normalized ┆ … ┆ Cost Of ┆ Total ┆ Operating ┆ gross_prof │\n",
+ "│ --- ┆ Of Unusual ┆ For Calcs ┆ EBITDA ┆ ┆ Revenue ┆ Revenue ┆ Revenue ┆ it_margin │\n",
+ "│ str ┆ Items ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n",
+ "│ ┆ --- ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
+ "│ ┆ f64 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
+ "│ 2023-12-31 ┆ -5.22e6 ┆ 0.087 ┆ 4.2800e9 ┆ … ┆ 1.8589e10 ┆ 2.3713e10 ┆ 6.3880e9 ┆ 0.216084 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2022-12-31 ┆ -2.916e6 ┆ 0.243 ┆ 3.8110e9 ┆ … ┆ 1.6215e10 ┆ 2.0773e10 ┆ 5.4450e9 ┆ 0.219419 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2021-12-31 ┆ -1.1696e7 ┆ 0.068 ┆ 2.0670e9 ┆ … ┆ 1.1056e10 ┆ 1.3857e10 ┆ 3.4900e9 ┆ 0.202136 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2020-12-31 ┆ -7.209e7 ┆ 0.27 ┆ 7.24e8 ┆ … ┆ 9.1120e9 ┆ 1.0571e10 ┆ 2.1190e9 ┆ 0.138019 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "import polars as pl\n",
+ "\n",
+ "fs.income_statement.with_columns(pl.col('*').forge_income_statement.gross_profit_margin(revenue_column='Total Revenue',cogs_column='Cost Of Revenue'))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (5, 50) date Tax Effect Of Unusual Items Tax Rate For Calcs Normalized EBITDA Total Unusual Items Total Unusual Items Excluding Goodwill Net Income From Continuing Operation Net Minority Interest Reconciled Depreciation Reconciled Cost Of Revenue EBITDA EBIT Net Interest Income Interest Expense Interest Income Normalized Income Net Income From Continuing And Discontinued Operation Total Expenses Total Operating Income As Reported Diluted Average Shares Basic Average Shares Diluted EPS Basic EPS Diluted NI Availto Com Stockholders Net Income Common Stockholders Net Income Net Income Including Noncontrolling Interests Net Income Continuous Operations Tax Provision Pretax Income Other Income Expense Other Non Operating Income Expenses Special Income Charges Other Special Charges Restructuring And Mergern Acquisition Earnings From Equity Interest Net Non Operating Interest Income Expense Interest Expense Non Operating Interest Income Non Operating Operating Income Operating Expense Depreciation Amortization Depletion Income Statement Depreciation And Amortization In Income Statement Selling General And Administration General And Administrative Expense Other Gand A Gross Profit Cost Of Revenue Total Revenue Operating Revenue net_profit_margin str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" -5.22e6 0.087 4.2800e9 -6e7 -6e7 3.0830e9 2.77e8 1.8501e10 4.2200e9 3.9430e9 -5.3500e8 5.65e8 3e7 3.1378e9 3.0830e9 1.9789e10 3.8640e9 3.029e8 3.015e8 10.18 10.23 3.0830e9 3.0830e9 3.0830e9 3.0830e9 3.0830e9 2.95e8 3.3780e9 -1.1e7 4e7 -6e7 null 6e7 9e6 -5.3500e8 5.65e8 3e7 3.9240e9 1.2000e9 1.89e8 1.89e8 1.0110e9 1.0110e9 1.0110e9 5.1240e9 1.8589e10 2.3713e10 6.3880e9 -0.618437 "2022-12-31 00:00:00" -2.916e6 0.243 3.8110e9 -1.2e7 -1.2e7 2.3580e9 2.82e8 1.6126e10 3.7990e9 3.5170e9 -3.7700e8 4.03e8 2.6e7 2.3671e9 2.3580e9 1.7299e10 3.4620e9 3.258e8 3.244e8 7.24 7.27 2.3580e9 2.3580e9 2.3580e9 2.3580e9 2.3580e9 7.56e8 3.1140e9 1.7e7 1.1e7 -1.2e7 null 1.2e7 1.8e7 -3.7700e8 4.03e8 2.6e7 3.4740e9 1.0840e9 1.93e8 1.93e8 8.91e8 8.91e8 8.91e8 4.5580e9 1.6215e10 2.0773e10 5.4450e9 -0.613344 "2021-12-31 00:00:00" -1.1696e7 0.068 2.0670e9 -1.7200e8 -1.7200e8 1.0990e9 2.95e8 1.0981e10 1.8950e9 1.6000e9 -3.9200e8 4.2e8 2.8e7 1.2593e9 1.0990e9 1.2099e10 1.7500e9 3.293e8 3.272e8 3.34 3.36 1.0990e9 1.0990e9 1.0990e9 1.0990e9 1.0990e9 8.1e7 1.1800e9 -1.8600e8 1e7 -1.7200e8 1.64e8 8e6 -2.4e7 -3.9200e8 4.2e8 2.8e7 1.7580e9 1.0430e9 2.2e8 2.2e8 8.23e8 8.23e8 8.23e8 2.8010e9 1.1056e10 1.3857e10 3.4900e9 -0.670997 "2020-12-31 00:00:00" -7.209e7 0.27 7.24e8 -2.6700e8 -2.6700e8 -2.6700e8 4.78e8 8.9800e9 4.57e8 -2.1e7 -4.1800e8 4.45e8 2.7e7 -7.209e7 -2.6700e8 1.0220e10 8.4e7 3.258e8 3.258e8 -0.82 -0.82 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -1.9900e8 -4.6600e8 -3.9900e8 9e6 -2.6700e8 null 2.67e8 -1.4100e8 -4.1800e8 4.45e8 2.7e7 3.51e8 1.1080e9 3.46e8 3.46e8 7.62e8 7.62e8 7.62e8 1.4590e9 9.1120e9 1.0571e10 2.1190e9 -0.828777 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null -1.5400e8 null null null null null null null null null null null null null null null null null
"
+ ],
+ "text/plain": [
+ "shape: (5, 50)\n",
+ "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
+ "│ date ┆ Tax Effect ┆ Tax Rate ┆ Normalized ┆ … ┆ Cost Of ┆ Total ┆ Operating ┆ net_profit │\n",
+ "│ --- ┆ Of Unusual ┆ For Calcs ┆ EBITDA ┆ ┆ Revenue ┆ Revenue ┆ Revenue ┆ _margin │\n",
+ "│ str ┆ Items ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n",
+ "│ ┆ --- ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
+ "│ ┆ f64 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
+ "│ 2023-12-31 ┆ -5.22e6 ┆ 0.087 ┆ 4.2800e9 ┆ … ┆ 1.8589e10 ┆ 2.3713e10 ┆ 6.3880e9 ┆ -0.618437 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2022-12-31 ┆ -2.916e6 ┆ 0.243 ┆ 3.8110e9 ┆ … ┆ 1.6215e10 ┆ 2.0773e10 ┆ 5.4450e9 ┆ -0.613344 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2021-12-31 ┆ -1.1696e7 ┆ 0.068 ┆ 2.0670e9 ┆ … ┆ 1.1056e10 ┆ 1.3857e10 ┆ 3.4900e9 ┆ -0.670997 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2020-12-31 ┆ -7.209e7 ┆ 0.27 ┆ 7.24e8 ┆ … ┆ 9.1120e9 ┆ 1.0571e10 ┆ 2.1190e9 ┆ -0.828777 │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │\n",
+ "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "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'))"
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/mortgage.ipynb b/notebooks/mortgage.ipynb
new file mode 100644
index 0000000..aecc9e3
--- /dev/null
+++ b/notebooks/mortgage.ipynb
@@ -0,0 +1,131 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Mortgage\n",
+ "\n",
+ "The Mortgage module contains mortgage objects that you enable you to assess mortgage metrics. You need to define these objects prior to running calcuations. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "2275.934140129842"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "from metric_forge.mortgage import *\n",
+ "\n",
+ "mortgage = Mortgage(principal=390000,annual_interest_rate=5.75,start_date='2023-09-01',term_years=30,extra_principal_payment=200)\n",
+ "mortgage.calculate_monthly_payment()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (360, 6) payment_number payment_date payment interest_payment principal_payment principal_remaining i64 str f64 f64 f64 f64 1 "2023-10-01" 2275.93414 1868.75 407.18414 389592.81586 2 "2023-10-31" 2275.93414 1866.798909 409.135231 389183.680629 3 "2023-11-30" 2275.93414 1864.83847 411.09567 388772.584959 4 "2023-12-30" 2275.93414 1862.868636 413.065504 388359.519455 5 "2024-01-29" 2275.93414 1860.889364 415.044776 387944.474679 … … … … … … 356 "2052-11-27" 2275.93414 53.752435 2222.181705 8995.717798 357 "2052-12-27" 2275.93414 43.104481 2232.829659 6762.888139 358 "2053-01-26" 2275.93414 32.405506 2243.528634 4519.359505 359 "2053-02-25" 2275.93414 21.655264 2254.278876 2265.080629 360 "2053-03-27" 2275.93414 10.853511 2265.080629 1.2655e-8
"
+ ],
+ "text/plain": [
+ "shape: (360, 6)\n",
+ "┌────────────────┬──────────────┬────────────┬──────────────────┬───────────────────┬─────────────────────┐\n",
+ "│ payment_number ┆ payment_date ┆ payment ┆ interest_payment ┆ principal_payment ┆ principal_remaining │\n",
+ "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
+ "│ i64 ┆ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
+ "╞════════════════╪══════════════╪════════════╪══════════════════╪═══════════════════╪═════════════════════╡\n",
+ "│ 1 ┆ 2023-10-01 ┆ 2275.93414 ┆ 1868.75 ┆ 407.18414 ┆ 389592.81586 │\n",
+ "│ 2 ┆ 2023-10-31 ┆ 2275.93414 ┆ 1866.798909 ┆ 409.135231 ┆ 389183.680629 │\n",
+ "│ 3 ┆ 2023-11-30 ┆ 2275.93414 ┆ 1864.83847 ┆ 411.09567 ┆ 388772.584959 │\n",
+ "│ 4 ┆ 2023-12-30 ┆ 2275.93414 ┆ 1862.868636 ┆ 413.065504 ┆ 388359.519455 │\n",
+ "│ 5 ┆ 2024-01-29 ┆ 2275.93414 ┆ 1860.889364 ┆ 415.044776 ┆ 387944.474679 │\n",
+ "│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n",
+ "│ 356 ┆ 2052-11-27 ┆ 2275.93414 ┆ 53.752435 ┆ 2222.181705 ┆ 8995.717798 │\n",
+ "│ 357 ┆ 2052-12-27 ┆ 2275.93414 ┆ 43.104481 ┆ 2232.829659 ┆ 6762.888139 │\n",
+ "│ 358 ┆ 2053-01-26 ┆ 2275.93414 ┆ 32.405506 ┆ 2243.528634 ┆ 4519.359505 │\n",
+ "│ 359 ┆ 2053-02-25 ┆ 2275.93414 ┆ 21.655264 ┆ 2254.278876 ┆ 2265.080629 │\n",
+ "│ 360 ┆ 2053-03-27 ┆ 2275.93414 ┆ 10.853511 ┆ 2265.080629 ┆ 1.2655e-8 │\n",
+ "└────────────────┴──────────────┴────────────┴──────────────────┴───────────────────┴─────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "mortgage.generate_amortization_schedule()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'new_term_years': 24.502707600761994, 'time_saved_years': 5.497292399238006}"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "mortgage.calculate_principal_only_payment()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'Old Monthly Payment': 2275.934140129842,\n",
+ " 'New Monthly Payment': 1877.492587282451,\n",
+ " 'Monthly Savings': 398.441552847391,\n",
+ " 'Break-Even Point (months)': 12.548891962367875,\n",
+ " 'Total Savings (over the loan term)': 138438.95902506076,\n",
+ " 'Should Refinance': True}"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "mortgage.refinance_assessment(RefinanceOption(new_loan_amount=340000,new_annual_interest_rate=5.25,new_term_years=30,associated_costs=5000))\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/operations.ipynb b/notebooks/operations.ipynb
new file mode 100644
index 0000000..266c154
--- /dev/null
+++ b/notebooks/operations.ipynb
@@ -0,0 +1,85 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Operations"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (3, 11) total_production_time units_produced time_period availability performance quality actual_output potential_output defective_units total_units_produced cycle_time i64 i64 i64 f64 f64 f64 i64 i64 i64 i64 f64 1200 100 10 0.95 0.9 0.98 950 1000 2 100 12.0 1300 110 10 0.9 0.85 0.97 980 1000 3 110 11.818182 1100 95 10 0.88 0.87 0.96 900 1000 4 95 11.578947
"
+ ],
+ "text/plain": [
+ "shape: (3, 11)\n",
+ "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
+ "│ total_produ ┆ units_produ ┆ time_period ┆ availabilit ┆ … ┆ potential_o ┆ defective_u ┆ total_units ┆ cycle_time │\n",
+ "│ ction_time ┆ ced ┆ --- ┆ y ┆ ┆ utput ┆ nits ┆ _produced ┆ --- │\n",
+ "│ --- ┆ --- ┆ i64 ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ f64 │\n",
+ "│ i64 ┆ i64 ┆ ┆ f64 ┆ ┆ i64 ┆ i64 ┆ i64 ┆ │\n",
+ "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
+ "│ 1200 ┆ 100 ┆ 10 ┆ 0.95 ┆ … ┆ 1000 ┆ 2 ┆ 100 ┆ 12.0 │\n",
+ "│ 1300 ┆ 110 ┆ 10 ┆ 0.9 ┆ … ┆ 1000 ┆ 3 ┆ 110 ┆ 11.818182 │\n",
+ "│ 1100 ┆ 95 ┆ 10 ┆ 0.88 ┆ … ┆ 1000 ┆ 4 ┆ 95 ┆ 11.578947 │\n",
+ "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "import polars as pl\n",
+ "\n",
+ "from metric_forge import *\n",
+ "\n",
+ "df = pl.DataFrame({\n",
+ " \"total_production_time\": [1200, 1300, 1100],\n",
+ " \"units_produced\": [100, 110, 95],\n",
+ " \"time_period\": [10, 10, 10],\n",
+ " \"availability\": [0.95, 0.90, 0.88],\n",
+ " \"performance\": [0.90, 0.85, 0.87],\n",
+ " \"quality\": [0.98, 0.97, 0.96],\n",
+ " \"actual_output\": [950, 980, 900],\n",
+ " \"potential_output\": [1000, 1000, 1000],\n",
+ " \"defective_units\": [2, 3, 4],\n",
+ " \"total_units_produced\": [100, 110, 95],\n",
+ " # \"order_date\": [pl.datetime(2023, 9, 1), pl.datetime(2023, 9, 2), pl.datetime(2023, 9, 3)],\n",
+ " # \"delivery_date\": [pl.datetime(2023, 9, 5), pl.datetime(2023, 9, 6), pl.datetime(2023, 9, 7)]\n",
+ "})\n",
+ "\n",
+ "df = df.with_columns(\n",
+ " pl.col('*').forge_operations.cycle_time(\"total_production_time\", \"units_produced\"),\n",
+ " # pl.col('*').forge_operations.throughput(\"units_produced\", \"time_period\"),\n",
+ " # pl.col('*').forge_operations.oee(\"availability\", \"performance\", \"quality\"),\n",
+ " # pl.col('*').forge_operations.capacity_utilization(\"actual_output\", \"potential_output\"),\n",
+ " # pl.col('*').forge_operations.defect_rate(\"defective_units\", \"total_units_produced\"),\n",
+ " # pl.col('*').forge_operations.lead_time(\"order_date\", \"delivery_date\")\n",
+ ")\n",
+ "\n",
+ "df\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/product_dev.ipynb b/notebooks/product_dev.ipynb
new file mode 100644
index 0000000..4e7d4f9
--- /dev/null
+++ b/notebooks/product_dev.ipynb
@@ -0,0 +1,224 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Product Development\n",
+ "You can use Product Development Metrics in two different ways:\n",
+ "* With Polars\n",
+ "* As a Single Value Function (SVF)\n",
+ "\n",
+ "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. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Underserved Customer Needs"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (10, 3) importance_score satisfaction_score opportunity_score i64 i64 f64 8 7 9.0 6 8 4.0 7 9 5.0 8 7 9.0 6 6 6.0 9 8 10.0 7 9 5.0 6 7 5.0 9 8 10.0 8 7 9.0
"
+ ],
+ "text/plain": [
+ "shape: (10, 3)\n",
+ "┌──────────────────┬────────────────────┬───────────────────┐\n",
+ "│ importance_score ┆ satisfaction_score ┆ opportunity_score │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ f64 │\n",
+ "╞══════════════════╪════════════════════╪═══════════════════╡\n",
+ "│ 8 ┆ 7 ┆ 9.0 │\n",
+ "│ 6 ┆ 8 ┆ 4.0 │\n",
+ "│ 7 ┆ 9 ┆ 5.0 │\n",
+ "│ 8 ┆ 7 ┆ 9.0 │\n",
+ "│ 6 ┆ 6 ┆ 6.0 │\n",
+ "│ 9 ┆ 8 ┆ 10.0 │\n",
+ "│ 7 ┆ 9 ┆ 5.0 │\n",
+ "│ 6 ┆ 7 ┆ 5.0 │\n",
+ "│ 9 ┆ 8 ┆ 10.0 │\n",
+ "│ 8 ┆ 7 ┆ 9.0 │\n",
+ "└──────────────────┴────────────────────┴───────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('importance_score'),\n",
+ " pl.col('satisfaction_score'),\n",
+ " pl.col('*').forge_product_dev.opportunity_score(importance_col='importance_score',satisfaction_col='satisfaction_score'))\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (10, 3) importance_score satisfaction_score customer_value_delivered i64 i64 f64 8 7 0.56 6 8 0.48 7 9 0.63 8 7 0.56 6 6 0.36 9 8 0.72 7 9 0.63 6 7 0.42 9 8 0.72 8 7 0.56
"
+ ],
+ "text/plain": [
+ "shape: (10, 3)\n",
+ "┌──────────────────┬────────────────────┬──────────────────────────┐\n",
+ "│ importance_score ┆ satisfaction_score ┆ customer_value_delivered │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ f64 │\n",
+ "╞══════════════════╪════════════════════╪══════════════════════════╡\n",
+ "│ 8 ┆ 7 ┆ 0.56 │\n",
+ "│ 6 ┆ 8 ┆ 0.48 │\n",
+ "│ 7 ┆ 9 ┆ 0.63 │\n",
+ "│ 8 ┆ 7 ┆ 0.56 │\n",
+ "│ 6 ┆ 6 ┆ 0.36 │\n",
+ "│ 9 ┆ 8 ┆ 0.72 │\n",
+ "│ 7 ┆ 9 ┆ 0.63 │\n",
+ "│ 6 ┆ 7 ┆ 0.42 │\n",
+ "│ 9 ┆ 8 ┆ 0.72 │\n",
+ "│ 8 ┆ 7 ┆ 0.56 │\n",
+ "└──────────────────┴────────────────────┴──────────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('importance_score'),\n",
+ " pl.col('satisfaction_score'),\n",
+ " pl.col('*').forge_product_dev.customer_value_delivered(importance_col='importance_score',satisfaction_col='satisfaction_score'))\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (10, 3) importance_score satisfaction_score opp_to_add_value i64 i64 f64 8 7 0.24 6 8 0.12 7 9 0.07 8 7 0.24 6 6 0.24 9 8 0.18 7 9 0.07 6 7 0.18 9 8 0.18 8 7 0.24
"
+ ],
+ "text/plain": [
+ "shape: (10, 3)\n",
+ "┌──────────────────┬────────────────────┬──────────────────┐\n",
+ "│ importance_score ┆ satisfaction_score ┆ opp_to_add_value │\n",
+ "│ --- ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ f64 │\n",
+ "╞══════════════════╪════════════════════╪══════════════════╡\n",
+ "│ 8 ┆ 7 ┆ 0.24 │\n",
+ "│ 6 ┆ 8 ┆ 0.12 │\n",
+ "│ 7 ┆ 9 ┆ 0.07 │\n",
+ "│ 8 ┆ 7 ┆ 0.24 │\n",
+ "│ 6 ┆ 6 ┆ 0.24 │\n",
+ "│ 9 ┆ 8 ┆ 0.18 │\n",
+ "│ 7 ┆ 9 ┆ 0.07 │\n",
+ "│ 6 ┆ 7 ┆ 0.18 │\n",
+ "│ 9 ┆ 8 ┆ 0.18 │\n",
+ "│ 8 ┆ 7 ┆ 0.24 │\n",
+ "└──────────────────┴────────────────────┴──────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.select(pl.col('importance_score'),\n",
+ " pl.col('satisfaction_score'),\n",
+ " pl.col('*').forge_product_dev.opportunity_to_add_value(importance_col='importance_score',satisfaction_col='satisfaction_score'))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (10, 4) importance_score satisfaction_score_before satisfaction_score_after customer_value_created i64 i64 i64 f64 8 7 9 0.16 9 8 9 0.09 7 9 8 -0.07 8 7 8 0.08 6 6 8 0.12 9 8 9 0.09 7 9 8 -0.07 6 7 6 -0.06 9 8 8 0.0 8 7 7 0.0
"
+ ],
+ "text/plain": [
+ "shape: (10, 4)\n",
+ "┌──────────────────┬───────────────────────────┬──────────────────────────┬────────────────────────┐\n",
+ "│ importance_score ┆ satisfaction_score_before ┆ satisfaction_score_after ┆ customer_value_created │\n",
+ "│ --- ┆ --- ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ i64 ┆ f64 │\n",
+ "╞══════════════════╪═══════════════════════════╪══════════════════════════╪════════════════════════╡\n",
+ "│ 8 ┆ 7 ┆ 9 ┆ 0.16 │\n",
+ "│ 9 ┆ 8 ┆ 9 ┆ 0.09 │\n",
+ "│ 7 ┆ 9 ┆ 8 ┆ -0.07 │\n",
+ "│ 8 ┆ 7 ┆ 8 ┆ 0.08 │\n",
+ "│ 6 ┆ 6 ┆ 8 ┆ 0.12 │\n",
+ "│ 9 ┆ 8 ┆ 9 ┆ 0.09 │\n",
+ "│ 7 ┆ 9 ┆ 8 ┆ -0.07 │\n",
+ "│ 6 ┆ 7 ┆ 6 ┆ -0.06 │\n",
+ "│ 9 ┆ 8 ┆ 8 ┆ 0.0 │\n",
+ "│ 8 ┆ 7 ┆ 7 ┆ 0.0 │\n",
+ "└──────────────────┴───────────────────────────┴──────────────────────────┴────────────────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "import polars as pl\n",
+ "data = pl.read_csv('datasets/customer-value-added.csv')\n",
+ "\n",
+ "data.select(pl.col('importance_score'),\n",
+ " pl.col('satisfaction_score_before'),\n",
+ " pl.col('satisfaction_score_after'),\n",
+ " pl.col('*').forge_product_dev.customer_value_created(importance_col='importance_score'\n",
+ " ,satisfaction_after_col='satisfaction_score_after'\n",
+ " ,satisfaction_before_col='satisfaction_score_before'))\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/web_traffic.ipynb b/notebooks/web_traffic.ipynb
new file mode 100644
index 0000000..3f21e52
--- /dev/null
+++ b/notebooks/web_traffic.ipynb
@@ -0,0 +1,344 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Web Traffic"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 8) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views i64 i64 i64 i64 i64 i64 i64 i64 1200 10 2 100 1000 50 5 50 1500 15 3 150 1500 75 7 70 60 2 1 0 0 0 2 20 2500 25 5 200 2000 100 10 100
"
+ ],
+ "text/plain": [
+ "shape: (4, 8)\n",
+ "┌────────────────┬───────────────┬───────────────┬────────────┬───────────────┬────────────┬───────┬───────────────┐\n",
+ "│ total_duration ┆ total_session ┆ single_page_s ┆ num_clicks ┆ num_impressio ┆ total_cost ┆ exits ┆ total_page_vi │\n",
+ "│ --- ┆ s ┆ essions ┆ --- ┆ ns ┆ --- ┆ --- ┆ ews │\n",
+ "│ i64 ┆ --- ┆ --- ┆ i64 ┆ --- ┆ i64 ┆ i64 ┆ --- │\n",
+ "│ ┆ i64 ┆ i64 ┆ ┆ i64 ┆ ┆ ┆ i64 │\n",
+ "╞════════════════╪═══════════════╪═══════════════╪════════════╪═══════════════╪════════════╪═══════╪═══════════════╡\n",
+ "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ 1000 ┆ 50 ┆ 5 ┆ 50 │\n",
+ "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ 1500 ┆ 75 ┆ 7 ┆ 70 │\n",
+ "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ 0 ┆ 0 ┆ 2 ┆ 20 │\n",
+ "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ 2000 ┆ 100 ┆ 10 ┆ 100 │\n",
+ "└────────────────┴───────────────┴───────────────┴────────────┴───────────────┴────────────┴───────┴───────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "from metric_forge.web_traffic import *\n",
+ "import polars as pl\n",
+ "\n",
+ "data = pl.read_csv('datasets/web_traffic.csv')\n",
+ "data"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Average Session Duration"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views average_session_duration i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 120.0 1500 15 3 150 1500 75 7 70 100.0 60 2 1 0 0 0 2 20 30.0 2500 25 5 200 2000 100 10 100 100.0
"
+ ],
+ "text/plain": [
+ "shape: (4, 9)\n",
+ "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
+ "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ average_sess │\n",
+ "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ ion_duration │\n",
+ "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
+ "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
+ "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 120.0 │\n",
+ "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 100.0 │\n",
+ "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 30.0 │\n",
+ "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 100.0 │\n",
+ "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.with_columns(pl.col('*').forge_web_traffic.average_session_duration(total_duration_col='total_duration', total_sessions_col='total_sessions'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Bounce Rate"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views bounce_rate i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 20.0 1500 15 3 150 1500 75 7 70 20.0 60 2 1 0 0 0 2 20 50.0 2500 25 5 200 2000 100 10 100 20.0
"
+ ],
+ "text/plain": [
+ "shape: (4, 9)\n",
+ "┌───────────────┬───────────────┬───────────────┬────────────┬───┬────────────┬───────┬──────────────┬─────────────┐\n",
+ "│ total_duratio ┆ total_session ┆ single_page_s ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ bounce_rate │\n",
+ "│ n ┆ s ┆ essions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ --- │\n",
+ "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ f64 │\n",
+ "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ │\n",
+ "╞═══════════════╪═══════════════╪═══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪═════════════╡\n",
+ "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 20.0 │\n",
+ "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 20.0 │\n",
+ "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 50.0 │\n",
+ "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 20.0 │\n",
+ "└───────────────┴───────────────┴───────────────┴────────────┴───┴────────────┴───────┴──────────────┴─────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.with_columns(pl.col('*').forge_web_traffic.bounce_rate(single_page_sessions_col='single_page_sessions', total_sessions_col='total_sessions'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Click Through Rate"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views click_through_rate i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 10.0 1500 15 3 150 1500 75 7 70 10.0 60 2 1 0 0 0 2 20 NaN 2500 25 5 200 2000 100 10 100 10.0
"
+ ],
+ "text/plain": [
+ "shape: (4, 9)\n",
+ "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
+ "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ click_throug │\n",
+ "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ h_rate │\n",
+ "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
+ "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
+ "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 10.0 │\n",
+ "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 10.0 │\n",
+ "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ NaN │\n",
+ "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 10.0 │\n",
+ "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.with_columns(pl.col('*').forge_web_traffic.click_through_rate(num_clicks_col='num_clicks', num_impressions_col='num_impressions'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Cost Per Click"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views cost_per_click i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 0.5 1500 15 3 150 1500 75 7 70 0.5 60 2 1 0 0 0 2 20 0.0 2500 25 5 200 2000 100 10 100 0.5
"
+ ],
+ "text/plain": [
+ "shape: (4, 9)\n",
+ "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
+ "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ cost_per_cli │\n",
+ "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ ck │\n",
+ "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
+ "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
+ "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 0.5 │\n",
+ "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 0.5 │\n",
+ "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 0.0 │\n",
+ "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 0.5 │\n",
+ "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.with_columns(pl.col('*').forge_web_traffic.cost_per_click(total_cost_col='total_cost',num_clicks_col='num_clicks'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Exit Rate"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views exit_rate i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 10.0 1500 15 3 150 1500 75 7 70 10.0 60 2 1 0 0 0 2 20 10.0 2500 25 5 200 2000 100 10 100 10.0
"
+ ],
+ "text/plain": [
+ "shape: (4, 9)\n",
+ "┌────────────────┬───────────────┬───────────────┬────────────┬───┬────────────┬───────┬───────────────┬───────────┐\n",
+ "│ total_duration ┆ total_session ┆ single_page_s ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_vi ┆ exit_rate │\n",
+ "│ --- ┆ s ┆ essions ┆ --- ┆ ┆ --- ┆ --- ┆ ews ┆ --- │\n",
+ "│ i64 ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ f64 │\n",
+ "│ ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ │\n",
+ "╞════════════════╪═══════════════╪═══════════════╪════════════╪═══╪════════════╪═══════╪═══════════════╪═══════════╡\n",
+ "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 10.0 │\n",
+ "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 10.0 │\n",
+ "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 10.0 │\n",
+ "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 10.0 │\n",
+ "└────────────────┴───────────────┴───────────────┴────────────┴───┴────────────┴───────┴───────────────┴───────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.with_columns(pl.col('*').forge_web_traffic.exit_rate(exits_col='exits',total_page_views_col='total_page_views'))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Pages Per Session"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views pages_per_session i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 5.0 1500 15 3 150 1500 75 7 70 4.666667 60 2 1 0 0 0 2 20 10.0 2500 25 5 200 2000 100 10 100 4.0
"
+ ],
+ "text/plain": [
+ "shape: (4, 9)\n",
+ "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
+ "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ pages_per_se │\n",
+ "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ ssion │\n",
+ "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
+ "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
+ "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
+ "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 5.0 │\n",
+ "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 4.666667 │\n",
+ "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 10.0 │\n",
+ "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 4.0 │\n",
+ "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "data.with_columns(pl.col('*').forge_web_traffic.pages_per_session(total_page_views_col='total_page_views',total_sessions_col='total_sessions'))"
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/pyproject.toml b/pyproject.toml
index be23a19..f99d3fb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,8 +17,9 @@ dependencies = [
[project.urls]
"Documentation" = "https://docs.metric-forge.com"
"Source" = "https://github.com/jrasband-dev/metric-forge"
-"Tracker" = "https://github.com/jrasband-dev/metric-forge/issues"
"Changelog" = "https://github.com/jrasband-dev/metric-forge/releases"
+"Tracker" = "https://github.com/jrasband-dev/metric-forge/issues"
+
"Contributors" = "https://github.com/jrasband-dev/metric-forge/graphs/contributors"
"Repository Stats" = "https://github.com/jrasband-dev/metric-forge/pulse"
"Download Stats" = "https://pypistats.org/packages/metric-forge"
diff --git a/readme.ipynb b/readme.ipynb
index 1724eb8..15f8030 100644
--- a/readme.ipynb
+++ b/readme.ipynb
@@ -41,1546 +41,6 @@
"pip install metric-forge\n",
"```"
]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Ecommerce\n",
- "You can use Ecommerce Metrics in two different ways:\n",
- "* With Polars\n",
- "* As a Single Value Function (SVF)\n",
- "\n",
- "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. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (5, 15) month total_revenue number_of_orders cost_of_acquisition new_customers carts_created completed_purchases revenue_from_ads advertising_spend num_conversions num_visitors revenue_per_customer average_customer_lifetime num_customers_lost total_customers_beginning str f64 i64 f64 i64 i64 i64 f64 f64 i64 i64 f64 f64 i64 i64 "2023-01" 87454.011885 991 22958.350559 406 1969 1425 81339.957696 5390.910169 300 13154 202.427329 3.159364 239 3306 "2023-02" 145071.430641 913 18736.874206 234 1506 1421 76875.083402 15585.037018 427 14762 116.173436 1.812245 124 4680 "2023-03" 123199.394181 1305 28355.586842 120 1497 965 116505.482191 14872.037954 367 10056 384.265156 4.771414 177 4675 "2023-04" 109865.84842 885 14184.81582 428 1963 1102 106008.046381 12337.204368 132 19948 144.356328 3.395462 299 2972 "2023-05" 65601.864044 691 18764.339456 266 1009 801 97258.809912 5351.995568 147 13110 275.734601 3.77914 296 3768
"
- ],
- "text/plain": [
- "shape: (5, 15)\n",
- "┌─────────┬──────────────┬──────────────┬──────────────┬───┬─────────────┬─────────────┬─────────────┬─────────────┐\n",
- "│ month ┆ total_revenu ┆ number_of_or ┆ cost_of_acqu ┆ … ┆ revenue_per ┆ average_cus ┆ num_custome ┆ total_custo │\n",
- "│ --- ┆ e ┆ ders ┆ isition ┆ ┆ _customer ┆ tomer_lifet ┆ rs_lost ┆ mers_beginn │\n",
- "│ str ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ ime ┆ --- ┆ ing │\n",
- "│ ┆ f64 ┆ i64 ┆ f64 ┆ ┆ f64 ┆ --- ┆ i64 ┆ --- │\n",
- "│ ┆ ┆ ┆ ┆ ┆ ┆ f64 ┆ ┆ i64 │\n",
- "╞═════════╪══════════════╪══════════════╪══════════════╪═══╪═════════════╪═════════════╪═════════════╪═════════════╡\n",
- "│ 2023-01 ┆ 87454.011885 ┆ 991 ┆ 22958.350559 ┆ … ┆ 202.427329 ┆ 3.159364 ┆ 239 ┆ 3306 │\n",
- "│ 2023-02 ┆ 145071.43064 ┆ 913 ┆ 18736.874206 ┆ … ┆ 116.173436 ┆ 1.812245 ┆ 124 ┆ 4680 │\n",
- "│ ┆ 1 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2023-03 ┆ 123199.39418 ┆ 1305 ┆ 28355.586842 ┆ … ┆ 384.265156 ┆ 4.771414 ┆ 177 ┆ 4675 │\n",
- "│ ┆ 1 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2023-04 ┆ 109865.84842 ┆ 885 ┆ 14184.81582 ┆ … ┆ 144.356328 ┆ 3.395462 ┆ 299 ┆ 2972 │\n",
- "│ 2023-05 ┆ 65601.864044 ┆ 691 ┆ 18764.339456 ┆ … ┆ 275.734601 ┆ 3.77914 ┆ 296 ┆ 3768 │\n",
- "└─────────┴──────────────┴──────────────┴──────────────┴───┴─────────────┴─────────────┴─────────────┴─────────────┘"
- ]
- },
- "execution_count": 1,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "from metric_forge.ecommerce import * \n",
- "import polars as pl\n",
- "data = pl.read_csv('datasets/ecommerce_metrics.csv')\n",
- "data.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### Customer Acquisition Cost"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (12, 3) cost_of_acquisition new_customers customer_acquisition_cost f64 i64 f64 22958.350559 406 56.547661 18736.874206 234 80.072112 28355.586842 120 236.296557 14184.81582 428 33.142093 18764.339456 266 70.54263 … … … 33555.278842 188 178.485526 15990.213465 415 38.530635 25427.033152 113 225.017992 27772.437066 341 81.444097 11393.512382 364 31.300858
"
- ],
- "text/plain": [
- "shape: (12, 3)\n",
- "┌─────────────────────┬───────────────┬───────────────────────────┐\n",
- "│ cost_of_acquisition ┆ new_customers ┆ customer_acquisition_cost │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ f64 ┆ i64 ┆ f64 │\n",
- "╞═════════════════════╪═══════════════╪═══════════════════════════╡\n",
- "│ 22958.350559 ┆ 406 ┆ 56.547661 │\n",
- "│ 18736.874206 ┆ 234 ┆ 80.072112 │\n",
- "│ 28355.586842 ┆ 120 ┆ 236.296557 │\n",
- "│ 14184.81582 ┆ 428 ┆ 33.142093 │\n",
- "│ 18764.339456 ┆ 266 ┆ 70.54263 │\n",
- "│ … ┆ … ┆ … │\n",
- "│ 33555.278842 ┆ 188 ┆ 178.485526 │\n",
- "│ 15990.213465 ┆ 415 ┆ 38.530635 │\n",
- "│ 25427.033152 ┆ 113 ┆ 225.017992 │\n",
- "│ 27772.437066 ┆ 341 ┆ 81.444097 │\n",
- "│ 11393.512382 ┆ 364 ┆ 31.300858 │\n",
- "└─────────────────────┴───────────────┴───────────────────────────┘"
- ]
- },
- "execution_count": 2,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('cost_of_acquisition'),\n",
- " pl.col('new_customers'),\n",
- " pl.col('*').forge_ecommerce.customer_acquisition_cost('cost_of_acquisition', 'new_customers'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### Average Order Value"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (12, 3) total_revenue new_customers average_order_value f64 i64 f64 87454.011885 406 88.248246 145071.430641 234 158.895324 123199.394181 120 94.405666 109865.84842 428 124.142202 65601.864044 266 94.937575 … … … 136617.614577 188 206.996386 110111.501174 415 114.819084 120807.25778 113 148.594413 52058.44943 341 99.920248 146990.985216 364 195.466736
"
- ],
- "text/plain": [
- "shape: (12, 3)\n",
- "┌───────────────┬───────────────┬─────────────────────┐\n",
- "│ total_revenue ┆ new_customers ┆ average_order_value │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ f64 ┆ i64 ┆ f64 │\n",
- "╞═══════════════╪═══════════════╪═════════════════════╡\n",
- "│ 87454.011885 ┆ 406 ┆ 88.248246 │\n",
- "│ 145071.430641 ┆ 234 ┆ 158.895324 │\n",
- "│ 123199.394181 ┆ 120 ┆ 94.405666 │\n",
- "│ 109865.84842 ┆ 428 ┆ 124.142202 │\n",
- "│ 65601.864044 ┆ 266 ┆ 94.937575 │\n",
- "│ … ┆ … ┆ … │\n",
- "│ 136617.614577 ┆ 188 ┆ 206.996386 │\n",
- "│ 110111.501174 ┆ 415 ┆ 114.819084 │\n",
- "│ 120807.25778 ┆ 113 ┆ 148.594413 │\n",
- "│ 52058.44943 ┆ 341 ┆ 99.920248 │\n",
- "│ 146990.985216 ┆ 364 ┆ 195.466736 │\n",
- "└───────────────┴───────────────┴─────────────────────┘"
- ]
- },
- "execution_count": 3,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('total_revenue'),\n",
- " pl.col('new_customers'),\n",
- " pl.col('*').forge_ecommerce.average_order_value('total_revenue', 'number_of_orders'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### Cart Abandonment Rate"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (12, 3) carts_created completed_purchases cart_abandonment_rate i64 i64 f64 1969 1425 27.628238 1506 1421 5.64409 1497 965 35.537742 1963 1102 43.861437 1009 801 20.61447 … … … 1108 601 45.758123 1975 1395 29.367089 800 669 16.375 2005 1215 39.401496 1704 855 49.823944
"
- ],
- "text/plain": [
- "shape: (12, 3)\n",
- "┌───────────────┬─────────────────────┬───────────────────────┐\n",
- "│ carts_created ┆ completed_purchases ┆ cart_abandonment_rate │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ f64 │\n",
- "╞═══════════════╪═════════════════════╪═══════════════════════╡\n",
- "│ 1969 ┆ 1425 ┆ 27.628238 │\n",
- "│ 1506 ┆ 1421 ┆ 5.64409 │\n",
- "│ 1497 ┆ 965 ┆ 35.537742 │\n",
- "│ 1963 ┆ 1102 ┆ 43.861437 │\n",
- "│ 1009 ┆ 801 ┆ 20.61447 │\n",
- "│ … ┆ … ┆ … │\n",
- "│ 1108 ┆ 601 ┆ 45.758123 │\n",
- "│ 1975 ┆ 1395 ┆ 29.367089 │\n",
- "│ 800 ┆ 669 ┆ 16.375 │\n",
- "│ 2005 ┆ 1215 ┆ 39.401496 │\n",
- "│ 1704 ┆ 855 ┆ 49.823944 │\n",
- "└───────────────┴─────────────────────┴───────────────────────┘"
- ]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('carts_created'),\n",
- " pl.col('completed_purchases'),\n",
- " pl.col('*').forge_ecommerce.cart_abandonment_rate('carts_created', 'completed_purchases'))\n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### Return on Advertising Spend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (12, 3) revenue_from_ads advertising_spend return_on_advertising_spend f64 f64 f64 81339.957696 5390.910169 15.088353 76875.083402 15585.037018 4.932621 116505.482191 14872.037954 7.833861 106008.046381 12337.204368 8.59255 97258.809912 5351.995568 18.172438 … … … 116872.977654 24754.388513 4.721303 84633.082292 20148.99937 4.200362 54839.926382 28157.521963 1.947612 56664.615513 21276.925638 2.663196 44874.024516 27873.991889 1.609889
"
- ],
- "text/plain": [
- "shape: (12, 3)\n",
- "┌──────────────────┬───────────────────┬─────────────────────────────┐\n",
- "│ revenue_from_ads ┆ advertising_spend ┆ return_on_advertising_spend │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ f64 ┆ f64 ┆ f64 │\n",
- "╞══════════════════╪═══════════════════╪═════════════════════════════╡\n",
- "│ 81339.957696 ┆ 5390.910169 ┆ 15.088353 │\n",
- "│ 76875.083402 ┆ 15585.037018 ┆ 4.932621 │\n",
- "│ 116505.482191 ┆ 14872.037954 ┆ 7.833861 │\n",
- "│ 106008.046381 ┆ 12337.204368 ┆ 8.59255 │\n",
- "│ 97258.809912 ┆ 5351.995568 ┆ 18.172438 │\n",
- "│ … ┆ … ┆ … │\n",
- "│ 116872.977654 ┆ 24754.388513 ┆ 4.721303 │\n",
- "│ 84633.082292 ┆ 20148.99937 ┆ 4.200362 │\n",
- "│ 54839.926382 ┆ 28157.521963 ┆ 1.947612 │\n",
- "│ 56664.615513 ┆ 21276.925638 ┆ 2.663196 │\n",
- "│ 44874.024516 ┆ 27873.991889 ┆ 1.609889 │\n",
- "└──────────────────┴───────────────────┴─────────────────────────────┘"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('revenue_from_ads'),\n",
- " pl.col('advertising_spend'),\n",
- " pl.col('*').forge_ecommerce.return_on_advertising_spend('revenue_from_ads', 'advertising_spend'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### Conversion Rate"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (12, 3) num_conversions num_visitors conversion_rate i64 i64 f64 300 13154 2.280675 427 14762 2.892562 367 10056 3.649562 132 19948 0.66172 147 13110 1.121281 … … … 392 8840 4.434389 198 6028 3.284672 271 12385 2.188131 459 5502 8.342421 313 11910 2.628044
"
- ],
- "text/plain": [
- "shape: (12, 3)\n",
- "┌─────────────────┬──────────────┬─────────────────┐\n",
- "│ num_conversions ┆ num_visitors ┆ conversion_rate │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ f64 │\n",
- "╞═════════════════╪══════════════╪═════════════════╡\n",
- "│ 300 ┆ 13154 ┆ 2.280675 │\n",
- "│ 427 ┆ 14762 ┆ 2.892562 │\n",
- "│ 367 ┆ 10056 ┆ 3.649562 │\n",
- "│ 132 ┆ 19948 ┆ 0.66172 │\n",
- "│ 147 ┆ 13110 ┆ 1.121281 │\n",
- "│ … ┆ … ┆ … │\n",
- "│ 392 ┆ 8840 ┆ 4.434389 │\n",
- "│ 198 ┆ 6028 ┆ 3.284672 │\n",
- "│ 271 ┆ 12385 ┆ 2.188131 │\n",
- "│ 459 ┆ 5502 ┆ 8.342421 │\n",
- "│ 313 ┆ 11910 ┆ 2.628044 │\n",
- "└─────────────────┴──────────────┴─────────────────┘"
- ]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('num_conversions'),\n",
- " pl.col('num_visitors'),\n",
- " pl.col('*').forge_ecommerce.conversion_rate('num_conversions', 'num_visitors'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### Customer Lifetime Value"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (12, 3) revenue_per_customer average_customer_lifetime customer_lifetime_value f64 f64 f64 202.427329 3.159364 639.54169 116.173436 1.812245 210.534716 384.265156 4.771414 1833.488253 144.356328 3.395462 490.156408 275.734601 3.77914 1042.039585 … … … 290.148089 2.182535 633.258286 325.310229 1.421977 462.583676 378.206435 2.826138 1068.863683 155.732582 1.873762 291.805755 341.766952 2.66604 911.164293
"
- ],
- "text/plain": [
- "shape: (12, 3)\n",
- "┌──────────────────────┬───────────────────────────┬─────────────────────────┐\n",
- "│ revenue_per_customer ┆ average_customer_lifetime ┆ customer_lifetime_value │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ f64 ┆ f64 ┆ f64 │\n",
- "╞══════════════════════╪═══════════════════════════╪═════════════════════════╡\n",
- "│ 202.427329 ┆ 3.159364 ┆ 639.54169 │\n",
- "│ 116.173436 ┆ 1.812245 ┆ 210.534716 │\n",
- "│ 384.265156 ┆ 4.771414 ┆ 1833.488253 │\n",
- "│ 144.356328 ┆ 3.395462 ┆ 490.156408 │\n",
- "│ 275.734601 ┆ 3.77914 ┆ 1042.039585 │\n",
- "│ … ┆ … ┆ … │\n",
- "│ 290.148089 ┆ 2.182535 ┆ 633.258286 │\n",
- "│ 325.310229 ┆ 1.421977 ┆ 462.583676 │\n",
- "│ 378.206435 ┆ 2.826138 ┆ 1068.863683 │\n",
- "│ 155.732582 ┆ 1.873762 ┆ 291.805755 │\n",
- "│ 341.766952 ┆ 2.66604 ┆ 911.164293 │\n",
- "└──────────────────────┴───────────────────────────┴─────────────────────────┘"
- ]
- },
- "execution_count": 7,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('revenue_per_customer'),\n",
- " pl.col('average_customer_lifetime'),\n",
- " pl.col('*').forge_ecommerce.customer_lifetime_value(revenue_per_customer_column='revenue_per_customer',average_customer_lifetime_column='average_customer_lifetime',method='basic'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Product Development\n",
- "You can use Product Development Metrics in two different ways:\n",
- "* With Polars\n",
- "* As a Single Value Function (SVF)\n",
- "\n",
- "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. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (10, 3) feature_name importance_score satisfaction_score str i64 i64 "Feature1" 8 7 "Feature2" 6 8 "Feature3" 7 9 "Feature4" 8 7 "Feature5" 6 6 "Feature6" 9 8 "Feature7" 7 9 "Feature8" 6 7 "Feature9" 9 8 "Feature10" 8 7
"
- ],
- "text/plain": [
- "shape: (10, 3)\n",
- "┌──────────────┬──────────────────┬────────────────────┐\n",
- "│ feature_name ┆ importance_score ┆ satisfaction_score │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ str ┆ i64 ┆ i64 │\n",
- "╞══════════════╪══════════════════╪════════════════════╡\n",
- "│ Feature1 ┆ 8 ┆ 7 │\n",
- "│ Feature2 ┆ 6 ┆ 8 │\n",
- "│ Feature3 ┆ 7 ┆ 9 │\n",
- "│ Feature4 ┆ 8 ┆ 7 │\n",
- "│ Feature5 ┆ 6 ┆ 6 │\n",
- "│ Feature6 ┆ 9 ┆ 8 │\n",
- "│ Feature7 ┆ 7 ┆ 9 │\n",
- "│ Feature8 ┆ 6 ┆ 7 │\n",
- "│ Feature9 ┆ 9 ┆ 8 │\n",
- "│ Feature10 ┆ 8 ┆ 7 │\n",
- "└──────────────┴──────────────────┴────────────────────┘"
- ]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "import polars as pl\n",
- "from metric_forge.product_development import *\n",
- "data = pl.read_csv('datasets/customer-value.csv')\n",
- "data"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Underserved Customer Needs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (10, 3) importance_score satisfaction_score opportunity_score i64 i64 f64 8 7 9.0 6 8 4.0 7 9 5.0 8 7 9.0 6 6 6.0 9 8 10.0 7 9 5.0 6 7 5.0 9 8 10.0 8 7 9.0
"
- ],
- "text/plain": [
- "shape: (10, 3)\n",
- "┌──────────────────┬────────────────────┬───────────────────┐\n",
- "│ importance_score ┆ satisfaction_score ┆ opportunity_score │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ f64 │\n",
- "╞══════════════════╪════════════════════╪═══════════════════╡\n",
- "│ 8 ┆ 7 ┆ 9.0 │\n",
- "│ 6 ┆ 8 ┆ 4.0 │\n",
- "│ 7 ┆ 9 ┆ 5.0 │\n",
- "│ 8 ┆ 7 ┆ 9.0 │\n",
- "│ 6 ┆ 6 ┆ 6.0 │\n",
- "│ 9 ┆ 8 ┆ 10.0 │\n",
- "│ 7 ┆ 9 ┆ 5.0 │\n",
- "│ 6 ┆ 7 ┆ 5.0 │\n",
- "│ 9 ┆ 8 ┆ 10.0 │\n",
- "│ 8 ┆ 7 ┆ 9.0 │\n",
- "└──────────────────┴────────────────────┴───────────────────┘"
- ]
- },
- "execution_count": 9,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('importance_score'),\n",
- " pl.col('satisfaction_score'),\n",
- " pl.col('*').forge_product_dev.opportunity_score(importance_col='importance_score',satisfaction_col='satisfaction_score'))\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (10, 3) importance_score satisfaction_score customer_value_delivered i64 i64 f64 8 7 0.56 6 8 0.48 7 9 0.63 8 7 0.56 6 6 0.36 9 8 0.72 7 9 0.63 6 7 0.42 9 8 0.72 8 7 0.56
"
- ],
- "text/plain": [
- "shape: (10, 3)\n",
- "┌──────────────────┬────────────────────┬──────────────────────────┐\n",
- "│ importance_score ┆ satisfaction_score ┆ customer_value_delivered │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ f64 │\n",
- "╞══════════════════╪════════════════════╪══════════════════════════╡\n",
- "│ 8 ┆ 7 ┆ 0.56 │\n",
- "│ 6 ┆ 8 ┆ 0.48 │\n",
- "│ 7 ┆ 9 ┆ 0.63 │\n",
- "│ 8 ┆ 7 ┆ 0.56 │\n",
- "│ 6 ┆ 6 ┆ 0.36 │\n",
- "│ 9 ┆ 8 ┆ 0.72 │\n",
- "│ 7 ┆ 9 ┆ 0.63 │\n",
- "│ 6 ┆ 7 ┆ 0.42 │\n",
- "│ 9 ┆ 8 ┆ 0.72 │\n",
- "│ 8 ┆ 7 ┆ 0.56 │\n",
- "└──────────────────┴────────────────────┴──────────────────────────┘"
- ]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('importance_score'),\n",
- " pl.col('satisfaction_score'),\n",
- " pl.col('*').forge_product_dev.customer_value_delivered(importance_col='importance_score',satisfaction_col='satisfaction_score'))\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (10, 3) importance_score satisfaction_score opp_to_add_value i64 i64 f64 8 7 0.24 6 8 0.12 7 9 0.07 8 7 0.24 6 6 0.24 9 8 0.18 7 9 0.07 6 7 0.18 9 8 0.18 8 7 0.24
"
- ],
- "text/plain": [
- "shape: (10, 3)\n",
- "┌──────────────────┬────────────────────┬──────────────────┐\n",
- "│ importance_score ┆ satisfaction_score ┆ opp_to_add_value │\n",
- "│ --- ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ f64 │\n",
- "╞══════════════════╪════════════════════╪══════════════════╡\n",
- "│ 8 ┆ 7 ┆ 0.24 │\n",
- "│ 6 ┆ 8 ┆ 0.12 │\n",
- "│ 7 ┆ 9 ┆ 0.07 │\n",
- "│ 8 ┆ 7 ┆ 0.24 │\n",
- "│ 6 ┆ 6 ┆ 0.24 │\n",
- "│ 9 ┆ 8 ┆ 0.18 │\n",
- "│ 7 ┆ 9 ┆ 0.07 │\n",
- "│ 6 ┆ 7 ┆ 0.18 │\n",
- "│ 9 ┆ 8 ┆ 0.18 │\n",
- "│ 8 ┆ 7 ┆ 0.24 │\n",
- "└──────────────────┴────────────────────┴──────────────────┘"
- ]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.select(pl.col('importance_score'),\n",
- " pl.col('satisfaction_score'),\n",
- " pl.col('*').forge_product_dev.opportunity_to_add_value(importance_col='importance_score',satisfaction_col='satisfaction_score'))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (10, 4) importance_score satisfaction_score_before satisfaction_score_after customer_value_created i64 i64 i64 f64 8 7 9 0.16 9 8 9 0.09 7 9 8 -0.07 8 7 8 0.08 6 6 8 0.12 9 8 9 0.09 7 9 8 -0.07 6 7 6 -0.06 9 8 8 0.0 8 7 7 0.0
"
- ],
- "text/plain": [
- "shape: (10, 4)\n",
- "┌──────────────────┬───────────────────────────┬──────────────────────────┬────────────────────────┐\n",
- "│ importance_score ┆ satisfaction_score_before ┆ satisfaction_score_after ┆ customer_value_created │\n",
- "│ --- ┆ --- ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ i64 ┆ f64 │\n",
- "╞══════════════════╪═══════════════════════════╪══════════════════════════╪════════════════════════╡\n",
- "│ 8 ┆ 7 ┆ 9 ┆ 0.16 │\n",
- "│ 9 ┆ 8 ┆ 9 ┆ 0.09 │\n",
- "│ 7 ┆ 9 ┆ 8 ┆ -0.07 │\n",
- "│ 8 ┆ 7 ┆ 8 ┆ 0.08 │\n",
- "│ 6 ┆ 6 ┆ 8 ┆ 0.12 │\n",
- "│ 9 ┆ 8 ┆ 9 ┆ 0.09 │\n",
- "│ 7 ┆ 9 ┆ 8 ┆ -0.07 │\n",
- "│ 6 ┆ 7 ┆ 6 ┆ -0.06 │\n",
- "│ 9 ┆ 8 ┆ 8 ┆ 0.0 │\n",
- "│ 8 ┆ 7 ┆ 7 ┆ 0.0 │\n",
- "└──────────────────┴───────────────────────────┴──────────────────────────┴────────────────────────┘"
- ]
- },
- "execution_count": 12,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "import polars as pl\n",
- "data = pl.read_csv('datasets/customer-value-added.csv')\n",
- "\n",
- "data.select(pl.col('importance_score'),\n",
- " pl.col('satisfaction_score_before'),\n",
- " pl.col('satisfaction_score_after'),\n",
- " pl.col('*').forge_product_dev.customer_value_created(importance_col='importance_score'\n",
- " ,satisfaction_after_col='satisfaction_score_after'\n",
- " ,satisfaction_before_col='satisfaction_score_before'))\n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Finance\n",
- "\n",
- "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. "
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Financial Statement Objects"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "Income Statement "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (5, 49) date Tax Effect Of Unusual Items Tax Rate For Calcs Normalized EBITDA Total Unusual Items Total Unusual Items Excluding Goodwill Net Income From Continuing Operation Net Minority Interest Reconciled Depreciation Reconciled Cost Of Revenue EBITDA EBIT Net Interest Income Interest Expense Interest Income Normalized Income Net Income From Continuing And Discontinued Operation Total Expenses Total Operating Income As Reported Diluted Average Shares Basic Average Shares Diluted EPS Basic EPS Diluted NI Availto Com Stockholders Net Income Common Stockholders Net Income Net Income Including Noncontrolling Interests Net Income Continuous Operations Tax Provision Pretax Income Other Income Expense Other Non Operating Income Expenses Special Income Charges Other Special Charges Restructuring And Mergern Acquisition Earnings From Equity Interest Net Non Operating Interest Income Expense Interest Expense Non Operating Interest Income Non Operating Operating Income Operating Expense Depreciation Amortization Depletion Income Statement Depreciation And Amortization In Income Statement Selling General And Administration General And Administrative Expense Other Gand A Gross Profit Cost Of Revenue Total Revenue Operating Revenue str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" -5.22e6 0.087 4.2800e9 -6e7 -6e7 3.0830e9 2.77e8 1.8501e10 4.2200e9 3.9430e9 -5.3500e8 5.65e8 3e7 3.1378e9 3.0830e9 1.9789e10 3.8640e9 3.029e8 3.015e8 10.18 10.23 3.0830e9 3.0830e9 3.0830e9 3.0830e9 3.0830e9 2.95e8 3.3780e9 -1.1e7 4e7 -6e7 null 6e7 9e6 -5.3500e8 5.65e8 3e7 3.9240e9 1.2000e9 1.89e8 1.89e8 1.0110e9 1.0110e9 1.0110e9 5.1240e9 1.8589e10 2.3713e10 6.3880e9 "2022-12-31 00:00:00" -2.916e6 0.243 3.8110e9 -1.2e7 -1.2e7 2.3580e9 2.82e8 1.6126e10 3.7990e9 3.5170e9 -3.7700e8 4.03e8 2.6e7 2.3671e9 2.3580e9 1.7299e10 3.4620e9 3.258e8 3.244e8 7.24 7.27 2.3580e9 2.3580e9 2.3580e9 2.3580e9 2.3580e9 7.56e8 3.1140e9 1.7e7 1.1e7 -1.2e7 null 1.2e7 1.8e7 -3.7700e8 4.03e8 2.6e7 3.4740e9 1.0840e9 1.93e8 1.93e8 8.91e8 8.91e8 8.91e8 4.5580e9 1.6215e10 2.0773e10 5.4450e9 "2021-12-31 00:00:00" -1.1696e7 0.068 2.0670e9 -1.7200e8 -1.7200e8 1.0990e9 2.95e8 1.0981e10 1.8950e9 1.6000e9 -3.9200e8 4.2e8 2.8e7 1.2593e9 1.0990e9 1.2099e10 1.7500e9 3.293e8 3.272e8 3.34 3.36 1.0990e9 1.0990e9 1.0990e9 1.0990e9 1.0990e9 8.1e7 1.1800e9 -1.8600e8 1e7 -1.7200e8 1.64e8 8e6 -2.4e7 -3.9200e8 4.2e8 2.8e7 1.7580e9 1.0430e9 2.2e8 2.2e8 8.23e8 8.23e8 8.23e8 2.8010e9 1.1056e10 1.3857e10 3.4900e9 "2020-12-31 00:00:00" -7.209e7 0.27 7.24e8 -2.6700e8 -2.6700e8 -2.6700e8 4.78e8 8.9800e9 4.57e8 -2.1e7 -4.1800e8 4.45e8 2.7e7 -7.209e7 -2.6700e8 1.0220e10 8.4e7 3.258e8 3.258e8 -0.82 -0.82 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -1.9900e8 -4.6600e8 -3.9900e8 9e6 -2.6700e8 null 2.67e8 -1.4100e8 -4.1800e8 4.45e8 2.7e7 3.51e8 1.1080e9 3.46e8 3.46e8 7.62e8 7.62e8 7.62e8 1.4590e9 9.1120e9 1.0571e10 2.1190e9 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null -1.5400e8 null null null null null null null null null null null null null null null null
"
- ],
- "text/plain": [
- "shape: (5, 49)\n",
- "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
- "│ date ┆ Tax Effect ┆ Tax Rate ┆ Normalized ┆ … ┆ Gross ┆ Cost Of ┆ Total ┆ Operating │\n",
- "│ --- ┆ Of Unusual ┆ For Calcs ┆ EBITDA ┆ ┆ Profit ┆ Revenue ┆ Revenue ┆ Revenue │\n",
- "│ str ┆ Items ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n",
- "│ ┆ --- ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
- "│ ┆ f64 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
- "│ 2023-12-31 ┆ -5.22e6 ┆ 0.087 ┆ 4.2800e9 ┆ … ┆ 5.1240e9 ┆ 1.8589e10 ┆ 2.3713e10 ┆ 6.3880e9 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2022-12-31 ┆ -2.916e6 ┆ 0.243 ┆ 3.8110e9 ┆ … ┆ 4.5580e9 ┆ 1.6215e10 ┆ 2.0773e10 ┆ 5.4450e9 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2021-12-31 ┆ -1.1696e7 ┆ 0.068 ┆ 2.0670e9 ┆ … ┆ 2.8010e9 ┆ 1.1056e10 ┆ 1.3857e10 ┆ 3.4900e9 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2020-12-31 ┆ -7.209e7 ┆ 0.27 ┆ 7.24e8 ┆ … ┆ 1.4590e9 ┆ 9.1120e9 ┆ 1.0571e10 ┆ 2.1190e9 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "Balance Sheet "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (5, 69) date Ordinary Shares Number Share Issued Net Debt Total Debt Tangible Book Value Invested Capital Working Capital Net Tangible Assets Capital Lease Obligations Common Stock Equity Total Capitalization Total Equity Gross Minority Interest Stockholders Equity Gains Losses Not Affecting Retained Earnings Other Equity Adjustments Treasury Stock Retained Earnings Additional Paid In Capital Capital Stock Common Stock Total Liabilities Net Minority Interest Total Non Current Liabilities Net Minority Interest Other Non Current Liabilities Non Current Deferred Liabilities Non Current Deferred Revenue Non Current Deferred Taxes Liabilities Long Term Debt And Capital Lease Obligation Long Term Capital Lease Obligation Long Term Debt Current Liabilities Other Current Liabilities Current Debt And Capital Lease Obligation Current Debt Payables And Accrued Expenses Current Accrued Expenses Payables Accounts Payable Total Assets Total Non Current Assets Other Non Current Assets Non Current Deferred Assets Non Current Deferred Taxes Assets Non Current Note Receivables Investments And Advances Long Term Equity Investment Goodwill And Other Intangible Assets Other Intangible Assets Goodwill Net PPE Accumulated Depreciation Gross PPE Construction In Progress Other Properties Machinery Furniture Equipment Buildings And Improvements Land And Improvements Properties Current Assets Other Current Assets Assets Held For Sale Current Prepaid Assets Receivables Accounts Receivable Allowance For Doubtful Accounts Receivable Gross Accounts Receivable Cash Cash Equivalents And Short Term Investments Cash And Cash Equivalents Cash Financial str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" 2.90539975e8 2.90539975e8 1.1535e10 1.2760e10 -1.8758e10 1.1191e10 -4.4510e9 -1.8758e10 8.87e8 -6.8200e8 1.0638e10 -6.8200e8 -6.8200e8 -6.4700e8 -6.4700e8 2.0929e10 1.4838e10 6.0510e9 5e6 5e6 2.6356e10 1.8594e10 5.1600e9 1.2270e9 1.0180e9 2.09e8 1.2207e10 8.87e8 1.1320e10 7.7620e9 3.3280e9 5.53e8 5.53e8 3.8810e9 3.1430e9 7.38e8 7.38e8 2.5674e10 2.2363e10 6.58e8 6.73e8 6.73e8 1.38e8 3.08e8 3.08e8 1.8076e10 9.1900e9 8.8860e9 2.5100e9 -8.9000e8 3.4000e9 7.2e7 9.29e8 6.22e8 1.1080e9 6.69e8 0.0 3.3110e9 2.61e8 null null 2.7120e9 2.7120e9 -1.9700e8 2.9090e9 3.38e8 3.38e8 null "2022-12-31 00:00:00" 3.106e8 3.106e8 9.5570e9 1.1098e10 -1.7051e10 1.0632e10 -4.0260e9 -1.7051e10 1.0340e9 5.68e8 9.9480e9 5.68e8 5.68e8 -7.2900e8 -7.2900e8 1.7015e10 1.2342e10 5.9650e9 5e6 5e6 2.4247e10 1.6908e10 5.1220e9 1.3720e9 1.0590e9 3.13e8 1.0414e10 1.0340e9 9.3800e9 7.3390e9 3.3140e9 6.84e8 6.84e8 3.3410e9 2.5950e9 7.46e8 7.46e8 2.4815e10 2.1502e10 5.84e8 2.4e8 2.4e8 1.52e8 3.35e8 3.35e8 1.7619e10 8.7470e9 8.8720e9 2.5720e9 -8.7400e8 3.4460e9 3.6e7 9.87e8 6.49e8 1.0860e9 6.88e8 0.0 3.3130e9 2.35e8 null null 2.5710e9 2.5710e9 -1.9100e8 2.7620e9 5.07e8 5.07e8 null "2021-12-31 00:00:00" 3.273e8 3.273e8 8.7450e9 1.1236e10 -1.6585e10 1.1552e10 -2.7810e9 -1.6585e10 1.0980e9 1.4140e9 1.0747e10 1.4140e9 1.4140e9 -3.4200e8 -3.4200e8 1.4446e10 1.0305e10 5.8920e9 5e6 5e6 2.4139e10 1.7732e10 5.9510e9 1.3500e9 1.1810e9 1.69e8 1.0431e10 1.0980e9 9.3330e9 6.4070e9 2.5220e9 8.05e8 8.05e8 3.0800e9 2.3540e9 7.26e8 7.26e8 2.5553e10 2.1927e10 6.04e8 2.28e8 2.28e8 1.44e8 3.87e8 3.87e8 1.7999e10 8.9260e9 9.0730e9 2.5650e9 -8.5000e8 3.4150e9 1.37e8 1.0620e9 5.45e8 9.85e8 6.86e8 0.0 3.6260e9 2.51e8 null 2.51e8 1.9820e9 1.9820e9 -1.8700e8 2.1690e9 1.3930e9 1.3930e9 null "2020-12-31 00:00:00" 3.244e8 3.244e8 9.4990e9 1.1199e10 -1.7734e10 1.0806e10 -2.9270e9 -1.7734e10 8.23e8 4.3e8 9.6330e9 4.3e8 4.3e8 -1.3500e8 -1.3500e8 1.4497e10 9.2060e9 5.8510e9 5e6 5e6 2.4271e10 1.8519e10 6.8680e9 1.6250e9 1.5420e9 8.3e7 1.0026e10 8.23e8 9.2030e9 5.7520e9 1.7690e9 1.1730e9 1.1730e9 2.8100e9 2.2830e9 5.27e8 5.27e8 2.4701e10 2.1876e10 6.16e8 2.49e8 2.49e8 1.59e8 4.22e8 null 1.8164e10 8.9890e9 9.1750e9 2.2660e9 -8.8800e8 3.1540e9 2.9e7 7.52e8 6.4e8 1.0450e9 6.88e8 0.0 2.8250e9 1.8e8 8e6 1.8e8 1.7680e9 1.7680e9 null null 8.77e8 8.77e8 null "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null 2.55e8 2.52e8 null null null null null null 2.25e8
"
- ],
- "text/plain": [
- "shape: (5, 69)\n",
- "┌──────────────┬─────────────┬─────────────┬───────────┬───┬─────────────┬─────────────┬─────────────┬─────────────┐\n",
- "│ date ┆ Ordinary ┆ Share ┆ Net Debt ┆ … ┆ Gross ┆ Cash Cash ┆ Cash And ┆ Cash │\n",
- "│ --- ┆ Shares ┆ Issued ┆ --- ┆ ┆ Accounts ┆ Equivalents ┆ Cash ┆ Financial │\n",
- "│ str ┆ Number ┆ --- ┆ f64 ┆ ┆ Receivable ┆ And Shor… ┆ Equivalents ┆ --- │\n",
- "│ ┆ --- ┆ f64 ┆ ┆ ┆ --- ┆ --- ┆ --- ┆ f64 │\n",
- "│ ┆ f64 ┆ ┆ ┆ ┆ f64 ┆ f64 ┆ f64 ┆ │\n",
- "╞══════════════╪═════════════╪═════════════╪═══════════╪═══╪═════════════╪═════════════╪═════════════╪═════════════╡\n",
- "│ 2023-12-31 ┆ 2.90539975e ┆ 2.90539975e ┆ 1.1535e10 ┆ … ┆ 2.9090e9 ┆ 3.38e8 ┆ 3.38e8 ┆ null │\n",
- "│ 00:00:00 ┆ 8 ┆ 8 ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2022-12-31 ┆ 3.106e8 ┆ 3.106e8 ┆ 9.5570e9 ┆ … ┆ 2.7620e9 ┆ 5.07e8 ┆ 5.07e8 ┆ null │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2021-12-31 ┆ 3.273e8 ┆ 3.273e8 ┆ 8.7450e9 ┆ … ┆ 2.1690e9 ┆ 1.3930e9 ┆ 1.3930e9 ┆ null │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2020-12-31 ┆ 3.244e8 ┆ 3.244e8 ┆ 9.4990e9 ┆ … ┆ null ┆ 8.77e8 ┆ 8.77e8 ┆ null │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ 2.25e8 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "└──────────────┴─────────────┴─────────────┴───────────┴───┴─────────────┴─────────────┴─────────────┴─────────────┘"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "Cash Flow "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (5, 44) date Free Cash Flow Repurchase Of Capital Stock Repayment Of Debt Issuance Of Debt Issuance Of Capital Stock Capital Expenditure End Cash Position Beginning Cash Position Changes In Cash Financing Cash Flow Cash Flow From Continuing Financing Activities Net Other Financing Charges Cash Dividends Paid Common Stock Dividend Paid Net Common Stock Issuance Common Stock Payments Common Stock Issuance Net Issuance Payments Of Debt Net Short Term Debt Issuance Net Long Term Debt Issuance Long Term Debt Payments Long Term Debt Issuance Investing Cash Flow Cash Flow From Continuing Investing Activities Net Other Investing Changes Net Business Purchase And Sale Sale Of Business Purchase Of Business Net PPE Purchase And Sale Sale Of PPE Capital Expenditure Reported Operating Cash Flow Cash Flow From Continuing Operating Activities Change In Working Capital Other Non Cash Items Stock Based Compensation Deferred Tax Deferred Income Tax Depreciation Amortization Depletion Depreciation And Amortization Depreciation Operating Gains Losses Net Income From Continuing Operations str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" 2.7180e9 -3.9530e9 -6.8400e8 1.9180e9 2.9e7 -4.5200e8 3.66e8 5.25e8 -1.5900e8 -2.8640e9 -2.8640e9 -1.3300e8 -5.8700e8 -5.8700e8 -3.9240e9 -3.9530e9 2.9e7 1.7800e9 5.46e8 1.2340e9 -6.8400e8 1.9180e9 -4.6500e8 -4.6500e8 1.7e7 -1.0100e8 null -1.0100e8 7.1e7 7.1e7 -4.5200e8 3.1700e9 3.1700e9 6.9e7 1.48e8 2.05e8 -6.1200e8 -6.1200e8 2.77e8 2.77e8 2.77e8 null 3.0830e9 "2022-12-31 00:00:00" 2.0310e9 -2.5660e9 -8.0400e8 9.83e8 0.0 -3.3200e8 5.25e8 1.4210e9 -8.9600e8 -2.9620e9 -2.9620e9 -7.2e7 -3.2100e8 -3.2100e8 -2.5660e9 -2.5660e9 0.0 -3e6 -1.8200e8 1.79e8 -8.0400e8 9.83e8 -2.9700e8 -2.9700e8 3.4e7 0.0 null 0.0 1e6 1e6 -3.3200e8 2.3630e9 2.3630e9 -5.4200e8 -2.0700e8 1.92e8 2.8e8 2.8e8 2.82e8 2.82e8 2.82e8 null 2.3580e9 "2021-12-31 00:00:00" 9.94e8 0.0 -2.1740e9 1.7930e9 2e6 -1.8300e8 1.4210e9 8.94e8 5.27e8 -4.6300e8 -4.6300e8 -2.3400e8 0.0 0.0 2e6 0.0 2e6 -2.3100e8 1.5e8 -3.8100e8 -2.1740e9 1.7930e9 -1.8700e8 -1.8700e8 -1.6e7 0.0 null 0.0 1.2e7 1.2e7 -1.8300e8 1.1770e9 1.1770e9 1.1e8 -3.9200e8 1.82e8 -2.8100e8 -2.8100e8 2.95e8 2.95e8 2.95e8 1.64e8 1.0990e9 "2020-12-31 00:00:00" 1.5040e9 -1.5000e8 -1.8870e9 3.5610e9 0.0 -1.3500e8 8.94e8 2.53e8 6.41e8 -1.0330e9 -1.0330e9 -1.1100e8 -1.5600e8 -1.5600e8 -1.5000e8 -1.5000e8 0.0 -6.1600e8 -2.2900e9 1.6740e9 -1.8870e9 3.5610e9 3.5e7 3.5e7 -9e7 2.6e8 2.6e8 null 2.6e8 2.6e8 -1.3500e8 1.6390e9 1.6390e9 -2.8e7 1.7300e9 2.01e8 -4.7800e8 -4.7800e8 4.78e8 4.78e8 4.78e8 3e6 -2.6700e8 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null 3.95e8 null null null null null null null null null null null null null null -1.4700e8 null
"
- ],
- "text/plain": [
- "shape: (5, 44)\n",
- "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
- "│ date ┆ Free Cash ┆ Repurchase ┆ Repayment ┆ … ┆ Depreciatio ┆ Depreciatio ┆ Operating ┆ Net Income │\n",
- "│ --- ┆ Flow ┆ Of Capital ┆ Of Debt ┆ ┆ n And Amort ┆ n ┆ Gains ┆ From │\n",
- "│ str ┆ --- ┆ Stock ┆ --- ┆ ┆ ization ┆ --- ┆ Losses ┆ Continuing │\n",
- "│ ┆ f64 ┆ --- ┆ f64 ┆ ┆ --- ┆ f64 ┆ --- ┆ Ope… │\n",
- "│ ┆ ┆ f64 ┆ ┆ ┆ f64 ┆ ┆ f64 ┆ --- │\n",
- "│ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ f64 │\n",
- "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
- "│ 2023-12-31 ┆ 2.7180e9 ┆ -3.9530e9 ┆ -6.8400e8 ┆ … ┆ 2.77e8 ┆ 2.77e8 ┆ null ┆ 3.0830e9 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2022-12-31 ┆ 2.0310e9 ┆ -2.5660e9 ┆ -8.0400e8 ┆ … ┆ 2.82e8 ┆ 2.82e8 ┆ null ┆ 2.3580e9 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2021-12-31 ┆ 9.94e8 ┆ 0.0 ┆ -2.1740e9 ┆ … ┆ 2.95e8 ┆ 2.95e8 ┆ 1.64e8 ┆ 1.0990e9 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2020-12-31 ┆ 1.5040e9 ┆ -1.5000e8 ┆ -1.8870e9 ┆ … ┆ 4.78e8 ┆ 4.78e8 ┆ 3e6 ┆ -2.6700e8 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ -1.4700e8 ┆ null │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/plain": [
- "FinancialStatements(ticker=MAR)"
- ]
- },
- "execution_count": 13,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "from metric_forge import *\n",
- "\n",
- "fs = import_financials(ticker='MAR',engine='yfinance')\n",
- "fs"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Income Statement"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (5, 50) date Tax Effect Of Unusual Items Tax Rate For Calcs Normalized EBITDA Total Unusual Items Total Unusual Items Excluding Goodwill Net Income From Continuing Operation Net Minority Interest Reconciled Depreciation Reconciled Cost Of Revenue EBITDA EBIT Net Interest Income Interest Expense Interest Income Normalized Income Net Income From Continuing And Discontinued Operation Total Expenses Total Operating Income As Reported Diluted Average Shares Basic Average Shares Diluted EPS Basic EPS Diluted NI Availto Com Stockholders Net Income Common Stockholders Net Income Net Income Including Noncontrolling Interests Net Income Continuous Operations Tax Provision Pretax Income Other Income Expense Other Non Operating Income Expenses Special Income Charges Other Special Charges Restructuring And Mergern Acquisition Earnings From Equity Interest Net Non Operating Interest Income Expense Interest Expense Non Operating Interest Income Non Operating Operating Income Operating Expense Depreciation Amortization Depletion Income Statement Depreciation And Amortization In Income Statement Selling General And Administration General And Administrative Expense Other Gand A Gross Profit Cost Of Revenue Total Revenue Operating Revenue gross_profit_margin str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" -5.22e6 0.087 4.2800e9 -6e7 -6e7 3.0830e9 2.77e8 1.8501e10 4.2200e9 3.9430e9 -5.3500e8 5.65e8 3e7 3.1378e9 3.0830e9 1.9789e10 3.8640e9 3.029e8 3.015e8 10.18 10.23 3.0830e9 3.0830e9 3.0830e9 3.0830e9 3.0830e9 2.95e8 3.3780e9 -1.1e7 4e7 -6e7 null 6e7 9e6 -5.3500e8 5.65e8 3e7 3.9240e9 1.2000e9 1.89e8 1.89e8 1.0110e9 1.0110e9 1.0110e9 5.1240e9 1.8589e10 2.3713e10 6.3880e9 0.216084 "2022-12-31 00:00:00" -2.916e6 0.243 3.8110e9 -1.2e7 -1.2e7 2.3580e9 2.82e8 1.6126e10 3.7990e9 3.5170e9 -3.7700e8 4.03e8 2.6e7 2.3671e9 2.3580e9 1.7299e10 3.4620e9 3.258e8 3.244e8 7.24 7.27 2.3580e9 2.3580e9 2.3580e9 2.3580e9 2.3580e9 7.56e8 3.1140e9 1.7e7 1.1e7 -1.2e7 null 1.2e7 1.8e7 -3.7700e8 4.03e8 2.6e7 3.4740e9 1.0840e9 1.93e8 1.93e8 8.91e8 8.91e8 8.91e8 4.5580e9 1.6215e10 2.0773e10 5.4450e9 0.219419 "2021-12-31 00:00:00" -1.1696e7 0.068 2.0670e9 -1.7200e8 -1.7200e8 1.0990e9 2.95e8 1.0981e10 1.8950e9 1.6000e9 -3.9200e8 4.2e8 2.8e7 1.2593e9 1.0990e9 1.2099e10 1.7500e9 3.293e8 3.272e8 3.34 3.36 1.0990e9 1.0990e9 1.0990e9 1.0990e9 1.0990e9 8.1e7 1.1800e9 -1.8600e8 1e7 -1.7200e8 1.64e8 8e6 -2.4e7 -3.9200e8 4.2e8 2.8e7 1.7580e9 1.0430e9 2.2e8 2.2e8 8.23e8 8.23e8 8.23e8 2.8010e9 1.1056e10 1.3857e10 3.4900e9 0.202136 "2020-12-31 00:00:00" -7.209e7 0.27 7.24e8 -2.6700e8 -2.6700e8 -2.6700e8 4.78e8 8.9800e9 4.57e8 -2.1e7 -4.1800e8 4.45e8 2.7e7 -7.209e7 -2.6700e8 1.0220e10 8.4e7 3.258e8 3.258e8 -0.82 -0.82 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -1.9900e8 -4.6600e8 -3.9900e8 9e6 -2.6700e8 null 2.67e8 -1.4100e8 -4.1800e8 4.45e8 2.7e7 3.51e8 1.1080e9 3.46e8 3.46e8 7.62e8 7.62e8 7.62e8 1.4590e9 9.1120e9 1.0571e10 2.1190e9 0.138019 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null -1.5400e8 null null null null null null null null null null null null null null null null null
"
- ],
- "text/plain": [
- "shape: (5, 50)\n",
- "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
- "│ date ┆ Tax Effect ┆ Tax Rate ┆ Normalized ┆ … ┆ Cost Of ┆ Total ┆ Operating ┆ gross_prof │\n",
- "│ --- ┆ Of Unusual ┆ For Calcs ┆ EBITDA ┆ ┆ Revenue ┆ Revenue ┆ Revenue ┆ it_margin │\n",
- "│ str ┆ Items ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n",
- "│ ┆ --- ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
- "│ ┆ f64 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
- "│ 2023-12-31 ┆ -5.22e6 ┆ 0.087 ┆ 4.2800e9 ┆ … ┆ 1.8589e10 ┆ 2.3713e10 ┆ 6.3880e9 ┆ 0.216084 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2022-12-31 ┆ -2.916e6 ┆ 0.243 ┆ 3.8110e9 ┆ … ┆ 1.6215e10 ┆ 2.0773e10 ┆ 5.4450e9 ┆ 0.219419 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2021-12-31 ┆ -1.1696e7 ┆ 0.068 ┆ 2.0670e9 ┆ … ┆ 1.1056e10 ┆ 1.3857e10 ┆ 3.4900e9 ┆ 0.202136 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2020-12-31 ┆ -7.209e7 ┆ 0.27 ┆ 7.24e8 ┆ … ┆ 9.1120e9 ┆ 1.0571e10 ┆ 2.1190e9 ┆ 0.138019 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
- ]
- },
- "execution_count": 14,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "import polars as pl\n",
- "\n",
- "fs.income_statement.with_columns(pl.col('*').forge_income_statement.gross_profit_margin(revenue_column='Total Revenue',cogs_column='Cost Of Revenue'))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (5, 50) date Tax Effect Of Unusual Items Tax Rate For Calcs Normalized EBITDA Total Unusual Items Total Unusual Items Excluding Goodwill Net Income From Continuing Operation Net Minority Interest Reconciled Depreciation Reconciled Cost Of Revenue EBITDA EBIT Net Interest Income Interest Expense Interest Income Normalized Income Net Income From Continuing And Discontinued Operation Total Expenses Total Operating Income As Reported Diluted Average Shares Basic Average Shares Diluted EPS Basic EPS Diluted NI Availto Com Stockholders Net Income Common Stockholders Net Income Net Income Including Noncontrolling Interests Net Income Continuous Operations Tax Provision Pretax Income Other Income Expense Other Non Operating Income Expenses Special Income Charges Other Special Charges Restructuring And Mergern Acquisition Earnings From Equity Interest Net Non Operating Interest Income Expense Interest Expense Non Operating Interest Income Non Operating Operating Income Operating Expense Depreciation Amortization Depletion Income Statement Depreciation And Amortization In Income Statement Selling General And Administration General And Administrative Expense Other Gand A Gross Profit Cost Of Revenue Total Revenue Operating Revenue net_profit_margin str f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 "2023-12-31 00:00:00" -5.22e6 0.087 4.2800e9 -6e7 -6e7 3.0830e9 2.77e8 1.8501e10 4.2200e9 3.9430e9 -5.3500e8 5.65e8 3e7 3.1378e9 3.0830e9 1.9789e10 3.8640e9 3.029e8 3.015e8 10.18 10.23 3.0830e9 3.0830e9 3.0830e9 3.0830e9 3.0830e9 2.95e8 3.3780e9 -1.1e7 4e7 -6e7 null 6e7 9e6 -5.3500e8 5.65e8 3e7 3.9240e9 1.2000e9 1.89e8 1.89e8 1.0110e9 1.0110e9 1.0110e9 5.1240e9 1.8589e10 2.3713e10 6.3880e9 -0.618437 "2022-12-31 00:00:00" -2.916e6 0.243 3.8110e9 -1.2e7 -1.2e7 2.3580e9 2.82e8 1.6126e10 3.7990e9 3.5170e9 -3.7700e8 4.03e8 2.6e7 2.3671e9 2.3580e9 1.7299e10 3.4620e9 3.258e8 3.244e8 7.24 7.27 2.3580e9 2.3580e9 2.3580e9 2.3580e9 2.3580e9 7.56e8 3.1140e9 1.7e7 1.1e7 -1.2e7 null 1.2e7 1.8e7 -3.7700e8 4.03e8 2.6e7 3.4740e9 1.0840e9 1.93e8 1.93e8 8.91e8 8.91e8 8.91e8 4.5580e9 1.6215e10 2.0773e10 5.4450e9 -0.613344 "2021-12-31 00:00:00" -1.1696e7 0.068 2.0670e9 -1.7200e8 -1.7200e8 1.0990e9 2.95e8 1.0981e10 1.8950e9 1.6000e9 -3.9200e8 4.2e8 2.8e7 1.2593e9 1.0990e9 1.2099e10 1.7500e9 3.293e8 3.272e8 3.34 3.36 1.0990e9 1.0990e9 1.0990e9 1.0990e9 1.0990e9 8.1e7 1.1800e9 -1.8600e8 1e7 -1.7200e8 1.64e8 8e6 -2.4e7 -3.9200e8 4.2e8 2.8e7 1.7580e9 1.0430e9 2.2e8 2.2e8 8.23e8 8.23e8 8.23e8 2.8010e9 1.1056e10 1.3857e10 3.4900e9 -0.670997 "2020-12-31 00:00:00" -7.209e7 0.27 7.24e8 -2.6700e8 -2.6700e8 -2.6700e8 4.78e8 8.9800e9 4.57e8 -2.1e7 -4.1800e8 4.45e8 2.7e7 -7.209e7 -2.6700e8 1.0220e10 8.4e7 3.258e8 3.258e8 -0.82 -0.82 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -2.6700e8 -1.9900e8 -4.6600e8 -3.9900e8 9e6 -2.6700e8 null 2.67e8 -1.4100e8 -4.1800e8 4.45e8 2.7e7 3.51e8 1.1080e9 3.46e8 3.46e8 7.62e8 7.62e8 7.62e8 1.4590e9 9.1120e9 1.0571e10 2.1190e9 -0.828777 "2019-12-31 00:00:00" null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null -1.5400e8 null null null null null null null null null null null null null null null null null
"
- ],
- "text/plain": [
- "shape: (5, 50)\n",
- "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
- "│ date ┆ Tax Effect ┆ Tax Rate ┆ Normalized ┆ … ┆ Cost Of ┆ Total ┆ Operating ┆ net_profit │\n",
- "│ --- ┆ Of Unusual ┆ For Calcs ┆ EBITDA ┆ ┆ Revenue ┆ Revenue ┆ Revenue ┆ _margin │\n",
- "│ str ┆ Items ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n",
- "│ ┆ --- ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
- "│ ┆ f64 ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
- "│ 2023-12-31 ┆ -5.22e6 ┆ 0.087 ┆ 4.2800e9 ┆ … ┆ 1.8589e10 ┆ 2.3713e10 ┆ 6.3880e9 ┆ -0.618437 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2022-12-31 ┆ -2.916e6 ┆ 0.243 ┆ 3.8110e9 ┆ … ┆ 1.6215e10 ┆ 2.0773e10 ┆ 5.4450e9 ┆ -0.613344 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2021-12-31 ┆ -1.1696e7 ┆ 0.068 ┆ 2.0670e9 ┆ … ┆ 1.1056e10 ┆ 1.3857e10 ┆ 3.4900e9 ┆ -0.670997 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2020-12-31 ┆ -7.209e7 ┆ 0.27 ┆ 7.24e8 ┆ … ┆ 9.1120e9 ┆ 1.0571e10 ┆ 2.1190e9 ┆ -0.828777 │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "│ 2019-12-31 ┆ null ┆ null ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │\n",
- "│ 00:00:00 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
- "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
- ]
- },
- "execution_count": 15,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "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'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Mortgage\n",
- "\n",
- "The Mortgage module contains mortgage objects that you enable you to assess mortgage metrics. You need to define these objects prior to running calcuations. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "2275.934140129842"
- ]
- },
- "execution_count": 16,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "from metric_forge.mortgage import *\n",
- "\n",
- "mortgage = Mortgage(principal=390000,annual_interest_rate=5.75,start_date='2023-09-01',term_years=30,extra_principal_payment=200)\n",
- "mortgage.calculate_monthly_payment()\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (360, 6) payment_number payment_date payment interest_payment principal_payment principal_remaining i64 str f64 f64 f64 f64 1 "2023-10-01" 2275.93414 1868.75 407.18414 389592.81586 2 "2023-10-31" 2275.93414 1866.798909 409.135231 389183.680629 3 "2023-11-30" 2275.93414 1864.83847 411.09567 388772.584959 4 "2023-12-30" 2275.93414 1862.868636 413.065504 388359.519455 5 "2024-01-29" 2275.93414 1860.889364 415.044776 387944.474679 … … … … … … 356 "2052-11-27" 2275.93414 53.752435 2222.181705 8995.717798 357 "2052-12-27" 2275.93414 43.104481 2232.829659 6762.888139 358 "2053-01-26" 2275.93414 32.405506 2243.528634 4519.359505 359 "2053-02-25" 2275.93414 21.655264 2254.278876 2265.080629 360 "2053-03-27" 2275.93414 10.853511 2265.080629 1.2655e-8
"
- ],
- "text/plain": [
- "shape: (360, 6)\n",
- "┌────────────────┬──────────────┬────────────┬──────────────────┬───────────────────┬─────────────────────┐\n",
- "│ payment_number ┆ payment_date ┆ payment ┆ interest_payment ┆ principal_payment ┆ principal_remaining │\n",
- "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
- "│ i64 ┆ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n",
- "╞════════════════╪══════════════╪════════════╪══════════════════╪═══════════════════╪═════════════════════╡\n",
- "│ 1 ┆ 2023-10-01 ┆ 2275.93414 ┆ 1868.75 ┆ 407.18414 ┆ 389592.81586 │\n",
- "│ 2 ┆ 2023-10-31 ┆ 2275.93414 ┆ 1866.798909 ┆ 409.135231 ┆ 389183.680629 │\n",
- "│ 3 ┆ 2023-11-30 ┆ 2275.93414 ┆ 1864.83847 ┆ 411.09567 ┆ 388772.584959 │\n",
- "│ 4 ┆ 2023-12-30 ┆ 2275.93414 ┆ 1862.868636 ┆ 413.065504 ┆ 388359.519455 │\n",
- "│ 5 ┆ 2024-01-29 ┆ 2275.93414 ┆ 1860.889364 ┆ 415.044776 ┆ 387944.474679 │\n",
- "│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n",
- "│ 356 ┆ 2052-11-27 ┆ 2275.93414 ┆ 53.752435 ┆ 2222.181705 ┆ 8995.717798 │\n",
- "│ 357 ┆ 2052-12-27 ┆ 2275.93414 ┆ 43.104481 ┆ 2232.829659 ┆ 6762.888139 │\n",
- "│ 358 ┆ 2053-01-26 ┆ 2275.93414 ┆ 32.405506 ┆ 2243.528634 ┆ 4519.359505 │\n",
- "│ 359 ┆ 2053-02-25 ┆ 2275.93414 ┆ 21.655264 ┆ 2254.278876 ┆ 2265.080629 │\n",
- "│ 360 ┆ 2053-03-27 ┆ 2275.93414 ┆ 10.853511 ┆ 2265.080629 ┆ 1.2655e-8 │\n",
- "└────────────────┴──────────────┴────────────┴──────────────────┴───────────────────┴─────────────────────┘"
- ]
- },
- "execution_count": 17,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mortgage.generate_amortization_schedule()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "{'new_term_years': 24.502707600761994, 'time_saved_years': 5.497292399238006}"
- ]
- },
- "execution_count": 18,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mortgage.calculate_principal_only_payment()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 19,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "{'Old Monthly Payment': 2275.934140129842,\n",
- " 'New Monthly Payment': 1877.492587282451,\n",
- " 'Monthly Savings': 398.441552847391,\n",
- " 'Break-Even Point (months)': 12.548891962367875,\n",
- " 'Total Savings (over the loan term)': 138438.95902506076,\n",
- " 'Should Refinance': True}"
- ]
- },
- "execution_count": 19,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mortgage.refinance_assessment(RefinanceOption(new_loan_amount=340000,new_annual_interest_rate=5.25,new_term_years=30,associated_costs=5000))\n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Web Traffic"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 20,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (4, 8) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views i64 i64 i64 i64 i64 i64 i64 i64 1200 10 2 100 1000 50 5 50 1500 15 3 150 1500 75 7 70 60 2 1 0 0 0 2 20 2500 25 5 200 2000 100 10 100
"
- ],
- "text/plain": [
- "shape: (4, 8)\n",
- "┌────────────────┬───────────────┬───────────────┬────────────┬───────────────┬────────────┬───────┬───────────────┐\n",
- "│ total_duration ┆ total_session ┆ single_page_s ┆ num_clicks ┆ num_impressio ┆ total_cost ┆ exits ┆ total_page_vi │\n",
- "│ --- ┆ s ┆ essions ┆ --- ┆ ns ┆ --- ┆ --- ┆ ews │\n",
- "│ i64 ┆ --- ┆ --- ┆ i64 ┆ --- ┆ i64 ┆ i64 ┆ --- │\n",
- "│ ┆ i64 ┆ i64 ┆ ┆ i64 ┆ ┆ ┆ i64 │\n",
- "╞════════════════╪═══════════════╪═══════════════╪════════════╪═══════════════╪════════════╪═══════╪═══════════════╡\n",
- "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ 1000 ┆ 50 ┆ 5 ┆ 50 │\n",
- "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ 1500 ┆ 75 ┆ 7 ┆ 70 │\n",
- "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ 0 ┆ 0 ┆ 2 ┆ 20 │\n",
- "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ 2000 ┆ 100 ┆ 10 ┆ 100 │\n",
- "└────────────────┴───────────────┴───────────────┴────────────┴───────────────┴────────────┴───────┴───────────────┘"
- ]
- },
- "execution_count": 20,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "from metric_forge.web_traffic import *\n",
- "import polars as pl\n",
- "\n",
- "data = pl.read_csv('datasets/web_traffic.csv')\n",
- "data"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Average Session Duration"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 21,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views average_session_duration i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 120.0 1500 15 3 150 1500 75 7 70 100.0 60 2 1 0 0 0 2 20 30.0 2500 25 5 200 2000 100 10 100 100.0
"
- ],
- "text/plain": [
- "shape: (4, 9)\n",
- "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
- "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ average_sess │\n",
- "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ ion_duration │\n",
- "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
- "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
- "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 120.0 │\n",
- "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 100.0 │\n",
- "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 30.0 │\n",
- "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 100.0 │\n",
- "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
- ]
- },
- "execution_count": 21,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.with_columns(pl.col('*').forge_web_traffic.average_session_duration(total_duration_col='total_duration', total_sessions_col='total_sessions'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Bounce Rate"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 22,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views bounce_rate i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 20.0 1500 15 3 150 1500 75 7 70 20.0 60 2 1 0 0 0 2 20 50.0 2500 25 5 200 2000 100 10 100 20.0
"
- ],
- "text/plain": [
- "shape: (4, 9)\n",
- "┌───────────────┬───────────────┬───────────────┬────────────┬───┬────────────┬───────┬──────────────┬─────────────┐\n",
- "│ total_duratio ┆ total_session ┆ single_page_s ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ bounce_rate │\n",
- "│ n ┆ s ┆ essions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ --- │\n",
- "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ f64 │\n",
- "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ │\n",
- "╞═══════════════╪═══════════════╪═══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪═════════════╡\n",
- "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 20.0 │\n",
- "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 20.0 │\n",
- "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 50.0 │\n",
- "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 20.0 │\n",
- "└───────────────┴───────────────┴───────────────┴────────────┴───┴────────────┴───────┴──────────────┴─────────────┘"
- ]
- },
- "execution_count": 22,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.with_columns(pl.col('*').forge_web_traffic.bounce_rate(single_page_sessions_col='single_page_sessions', total_sessions_col='total_sessions'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Click Through Rate"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 23,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views click_through_rate i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 10.0 1500 15 3 150 1500 75 7 70 10.0 60 2 1 0 0 0 2 20 NaN 2500 25 5 200 2000 100 10 100 10.0
"
- ],
- "text/plain": [
- "shape: (4, 9)\n",
- "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
- "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ click_throug │\n",
- "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ h_rate │\n",
- "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
- "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
- "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 10.0 │\n",
- "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 10.0 │\n",
- "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ NaN │\n",
- "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 10.0 │\n",
- "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
- ]
- },
- "execution_count": 23,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.with_columns(pl.col('*').forge_web_traffic.click_through_rate(num_clicks_col='num_clicks', num_impressions_col='num_impressions'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Cost Per Click"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 24,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views cost_per_click i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 0.5 1500 15 3 150 1500 75 7 70 0.5 60 2 1 0 0 0 2 20 0.0 2500 25 5 200 2000 100 10 100 0.5
"
- ],
- "text/plain": [
- "shape: (4, 9)\n",
- "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
- "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ cost_per_cli │\n",
- "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ ck │\n",
- "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
- "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
- "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 0.5 │\n",
- "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 0.5 │\n",
- "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 0.0 │\n",
- "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 0.5 │\n",
- "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
- ]
- },
- "execution_count": 24,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.with_columns(pl.col('*').forge_web_traffic.cost_per_click(total_cost_col='total_cost',num_clicks_col='num_clicks'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Exit Rate"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 25,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views exit_rate i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 10.0 1500 15 3 150 1500 75 7 70 10.0 60 2 1 0 0 0 2 20 10.0 2500 25 5 200 2000 100 10 100 10.0
"
- ],
- "text/plain": [
- "shape: (4, 9)\n",
- "┌────────────────┬───────────────┬───────────────┬────────────┬───┬────────────┬───────┬───────────────┬───────────┐\n",
- "│ total_duration ┆ total_session ┆ single_page_s ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_vi ┆ exit_rate │\n",
- "│ --- ┆ s ┆ essions ┆ --- ┆ ┆ --- ┆ --- ┆ ews ┆ --- │\n",
- "│ i64 ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ f64 │\n",
- "│ ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ │\n",
- "╞════════════════╪═══════════════╪═══════════════╪════════════╪═══╪════════════╪═══════╪═══════════════╪═══════════╡\n",
- "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 10.0 │\n",
- "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 10.0 │\n",
- "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 10.0 │\n",
- "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 10.0 │\n",
- "└────────────────┴───────────────┴───────────────┴────────────┴───┴────────────┴───────┴───────────────┴───────────┘"
- ]
- },
- "execution_count": 25,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.with_columns(pl.col('*').forge_web_traffic.exit_rate(exits_col='exits',total_page_views_col='total_page_views'))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Pages Per Session"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 26,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (4, 9) total_duration total_sessions single_page_sessions num_clicks num_impressions total_cost exits total_page_views pages_per_session i64 i64 i64 i64 i64 i64 i64 i64 f64 1200 10 2 100 1000 50 5 50 5.0 1500 15 3 150 1500 75 7 70 4.666667 60 2 1 0 0 0 2 20 10.0 2500 25 5 200 2000 100 10 100 4.0
"
- ],
- "text/plain": [
- "shape: (4, 9)\n",
- "┌───────────────┬───────────────┬──────────────┬────────────┬───┬────────────┬───────┬──────────────┬──────────────┐\n",
- "│ total_duratio ┆ total_session ┆ single_page_ ┆ num_clicks ┆ … ┆ total_cost ┆ exits ┆ total_page_v ┆ pages_per_se │\n",
- "│ n ┆ s ┆ sessions ┆ --- ┆ ┆ --- ┆ --- ┆ iews ┆ ssion │\n",
- "│ --- ┆ --- ┆ --- ┆ i64 ┆ ┆ i64 ┆ i64 ┆ --- ┆ --- │\n",
- "│ i64 ┆ i64 ┆ i64 ┆ ┆ ┆ ┆ ┆ i64 ┆ f64 │\n",
- "╞═══════════════╪═══════════════╪══════════════╪════════════╪═══╪════════════╪═══════╪══════════════╪══════════════╡\n",
- "│ 1200 ┆ 10 ┆ 2 ┆ 100 ┆ … ┆ 50 ┆ 5 ┆ 50 ┆ 5.0 │\n",
- "│ 1500 ┆ 15 ┆ 3 ┆ 150 ┆ … ┆ 75 ┆ 7 ┆ 70 ┆ 4.666667 │\n",
- "│ 60 ┆ 2 ┆ 1 ┆ 0 ┆ … ┆ 0 ┆ 2 ┆ 20 ┆ 10.0 │\n",
- "│ 2500 ┆ 25 ┆ 5 ┆ 200 ┆ … ┆ 100 ┆ 10 ┆ 100 ┆ 4.0 │\n",
- "└───────────────┴───────────────┴──────────────┴────────────┴───┴────────────┴───────┴──────────────┴──────────────┘"
- ]
- },
- "execution_count": 26,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "data.with_columns(pl.col('*').forge_web_traffic.pages_per_session(total_page_views_col='total_page_views',total_sessions_col='total_sessions'))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 27,
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
shape: (3, 11) total_production_time units_produced time_period availability performance quality actual_output potential_output defective_units total_units_produced cycle_time i64 i64 i64 f64 f64 f64 i64 i64 i64 i64 f64 1200 100 10 0.95 0.9 0.98 950 1000 2 100 12.0 1300 110 10 0.9 0.85 0.97 980 1000 3 110 11.818182 1100 95 10 0.88 0.87 0.96 900 1000 4 95 11.578947
"
- ],
- "text/plain": [
- "shape: (3, 11)\n",
- "┌─────────────┬─────────────┬─────────────┬─────────────┬───┬─────────────┬─────────────┬─────────────┬────────────┐\n",
- "│ total_produ ┆ units_produ ┆ time_period ┆ availabilit ┆ … ┆ potential_o ┆ defective_u ┆ total_units ┆ cycle_time │\n",
- "│ ction_time ┆ ced ┆ --- ┆ y ┆ ┆ utput ┆ nits ┆ _produced ┆ --- │\n",
- "│ --- ┆ --- ┆ i64 ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ f64 │\n",
- "│ i64 ┆ i64 ┆ ┆ f64 ┆ ┆ i64 ┆ i64 ┆ i64 ┆ │\n",
- "╞═════════════╪═════════════╪═════════════╪═════════════╪═══╪═════════════╪═════════════╪═════════════╪════════════╡\n",
- "│ 1200 ┆ 100 ┆ 10 ┆ 0.95 ┆ … ┆ 1000 ┆ 2 ┆ 100 ┆ 12.0 │\n",
- "│ 1300 ┆ 110 ┆ 10 ┆ 0.9 ┆ … ┆ 1000 ┆ 3 ┆ 110 ┆ 11.818182 │\n",
- "│ 1100 ┆ 95 ┆ 10 ┆ 0.88 ┆ … ┆ 1000 ┆ 4 ┆ 95 ┆ 11.578947 │\n",
- "└─────────────┴─────────────┴─────────────┴─────────────┴───┴─────────────┴─────────────┴─────────────┴────────────┘"
- ]
- },
- "execution_count": 27,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "import polars as pl\n",
- "\n",
- "from metric_forge import *\n",
- "\n",
- "df = pl.DataFrame({\n",
- " \"total_production_time\": [1200, 1300, 1100],\n",
- " \"units_produced\": [100, 110, 95],\n",
- " \"time_period\": [10, 10, 10],\n",
- " \"availability\": [0.95, 0.90, 0.88],\n",
- " \"performance\": [0.90, 0.85, 0.87],\n",
- " \"quality\": [0.98, 0.97, 0.96],\n",
- " \"actual_output\": [950, 980, 900],\n",
- " \"potential_output\": [1000, 1000, 1000],\n",
- " \"defective_units\": [2, 3, 4],\n",
- " \"total_units_produced\": [100, 110, 95],\n",
- " # \"order_date\": [pl.datetime(2023, 9, 1), pl.datetime(2023, 9, 2), pl.datetime(2023, 9, 3)],\n",
- " # \"delivery_date\": [pl.datetime(2023, 9, 5), pl.datetime(2023, 9, 6), pl.datetime(2023, 9, 7)]\n",
- "})\n",
- "\n",
- "df = df.with_columns(\n",
- " pl.col('*').forge_operations.cycle_time(\"total_production_time\", \"units_produced\"),\n",
- " # pl.col('*').forge_operations.throughput(\"units_produced\", \"time_period\"),\n",
- " # pl.col('*').forge_operations.oee(\"availability\", \"performance\", \"quality\"),\n",
- " # pl.col('*').forge_operations.capacity_utilization(\"actual_output\", \"potential_output\"),\n",
- " # pl.col('*').forge_operations.defect_rate(\"defective_units\", \"total_units_produced\"),\n",
- " # pl.col('*').forge_operations.lead_time(\"order_date\", \"delivery_date\")\n",
- ")\n",
- "\n",
- "df\n"
- ]
}
],
"metadata": {