Skip to content

Commit

Permalink
doc: Updated example to include user-defined price thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
Franklin Aryee committed Jan 31, 2025
1 parent 52de6b2 commit 1b2c650
Showing 1 changed file with 80 additions and 12 deletions.
92 changes: 80 additions & 12 deletions docs/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
"source": [
"## Get Revenue Share for each Product Category\n",
"\n",
"Another feature of `saleanalyzer`, the `segment_revenue_share()` function, segments products into three categories (cheap < medium < expensive) — based on their price, and calculates the respective share of total revenue contributed by each segment. This function is particularly useful for analyzing product sales data and understanding revenue distribution across different pricing tiers.\n",
"Another feature of `saleanalyzer`, the `segment_revenue_share()` function, segments products into three categories (cheap < medium < expensive) — based on their price, and calculates the respective share of total revenue contributed by each segment. By default, the price thresholds are set automatically, but users can define custom thresholds to categorize products according to their specific business needs. This function is particularly useful for analyzing product sales data and understanding revenue distribution across different pricing tiers.\n",
"> Use help(sales_summary_statistics) for more information about the function"
]
},
Expand Down Expand Up @@ -337,10 +337,83 @@
}
],
"source": [
"# Using default price thresholds\n",
"revenue_share = segment_revenue_share(sample_data, price_col='UnitPrice', quantity_col='Quantity')\n",
"revenue_share"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PriceSegment</th>\n",
" <th>TotalRevenue</th>\n",
" <th>RevenueShare (%)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>cheap</td>\n",
" <td>1150</td>\n",
" <td>9.24</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>medium</td>\n",
" <td>3600</td>\n",
" <td>28.92</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>expensive</td>\n",
" <td>7700</td>\n",
" <td>61.85</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PriceSegment TotalRevenue RevenueShare (%)\n",
"0 cheap 1150 9.24\n",
"1 medium 3600 28.92\n",
"2 expensive 7700 61.85"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Using user-defined price thresholds\n",
"revenue_share = segment_revenue_share(sample_data, price_col='UnitPrice', quantity_col='Quantity', price_thresholds=(300, 500))\n",
"revenue_share"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -356,7 +429,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -409,7 +482,7 @@
"1 1.33"
]
},
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -441,7 +514,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -494,7 +567,7 @@
"1 1.88"
]
},
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -509,16 +582,11 @@
"source": [
"This is the end of the tutorial, where you have seen how to get sales data insights using our package."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "salesanalyzser",
"display_name": "salesanalyzer",
"language": "python",
"name": "python3"
},
Expand All @@ -532,7 +600,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 1b2c650

Please sign in to comment.