Skip to content

Commit fbd9960

Browse files
authored
Merge pull request #280 from Data-Simply/feature/plotstyler-graph-utils
Refactor graph_utils.py: Replace hardcoded styling with modular PlotStyler system
2 parents 45d16c4 + 1d3eee6 commit fbd9960

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+751
-227
lines changed

docs/analysis_modules.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,10 @@ from pyretailscience.analysis import cross_shop
779779

780780
data = {
781781
"customer_id": [1, 2, 3, 4, 5, 5, 6, 9, 7, 7, 8, 9, 5, 8],
782-
"category_name" = [
783-
"Electronics", "Clothing", "Home", "Sports", "Clothing", "Electronics", "Electronics"
782+
"category_name" : [
783+
"Electronics", "Clothing", "Home", "Sports", "Clothing", "Electronics", "Electronics",
784784
"Clothing", "Home", "Electronics", "Clothing", "Electronics", "Home", "Home"
785-
]
785+
],
786786
"unit_spend": [100, 200, 300, 400, 200, 500, 100, 200, 300, 350, 400, 500, 250, 360]
787787
}
788788

@@ -1148,9 +1148,9 @@ rfm_results = rfm_segmenter.df
11481148

11491149
| customer_id | recency_days | frequency | monetary | r_score | f_score | m_score | rfm_segment | fm_segment |
11501150
|-------------|--------------|-----------|----------|---------|---------|---------|-------------|------------|
1151-
| 1 | 113 | 2 | 125 | 0 | 0 | 0 | 0 | 0 |
1151+
| 1 | 113 | 2 | 125 | 2 | 0 | 0 | 200 | 0 |
11521152
| 2 | 127 | 2 | 250 | 1 | 1 | 1 | 111 | 11 |
1153-
| 3 | 147 | 3 | 750 | 2 | 2 | 2 | 222 | 22 |
1153+
| 3 | 147 | 3 | 750 | 0 | 2 | 2 | 22 | 22 |
11541154

11551155
### Purchases Per Customer
11561156

@@ -1360,9 +1360,9 @@ result_df.groupby("period_name").agg(
13601360

13611361
| period_name | transaction_count | total_sales | avg_transaction_value |
13621362
|:---------------|------------------:|------------:|----------------------:|
1363-
| Pre-Promotion | 31 | 1937.5 | 62.50 |
1364-
| Promotion | 28 | 1750.0 | 62.50 |
1365-
| Post-Promotion | 31 | 1937.5 | 62.50 |
1363+
| Pre-Promotion | 31 | 3050.0 | 98.39 |
1364+
| Promotion | 28 | 2800.0 | 100.00 |
1365+
| Post-Promotion | 31 | 3150.0 | 101.61 |
13661366

13671367
### Find Overlapping Periods
13681368

docs/api/plots/style/graph_utils.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/api/plots/style/tailwind.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/api/plots/styles/graph_utils.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Graph Utils
2+
3+
::: pyretailscience.plots.styles.graph_utils
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Styling Context
2+
3+
::: pyretailscience.plots.styles.styling_context
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Styling Helpers
2+
3+
::: pyretailscience.plots.styles.styling_helpers

docs/api/plots/styles/tailwind.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Tailwind Colors
2+
3+
::: pyretailscience.plots.styles.tailwind

docs/examples/segmentation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@
702702
}
703703
],
704704
"source": [
705-
"from pyretailscience.style.graph_utils import GraphStyles\n",
705+
"from pyretailscience.plots.styles.graph_utils import GraphStyles\n",
706706
"\n",
707707
"ax = seg_stats.plot(\n",
708708
" figsize=(10, 5),\n",

mkdocs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ nav:
4747
- Time Plot: api/plots/time.md
4848
- Venn Diagram: api/plots/venn.md
4949
- Waterfall Plot: api/plots/waterfall.md
50-
- Style:
51-
- Graph Utils: api/plots/style/graph_utils.md
52-
- Tailwind Colors: api/plots/style/tailwind.md
50+
- Styles:
51+
- Graph Utils: api/plots/styles/graph_utils.md
52+
- Tailwind Colors: api/plots/styles/tailwind.md
53+
- Styling Context: api/plots/styles/styling_context.md
54+
- Styling Helpers: api/plots/styles/styling_helpers.md
5355
- Utils:
5456
- Date Utils: api/utils/date.md
5557
- Columns Utils: api/utils/columns.md

pyretailscience/analysis/customer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import pandas as pd
77
from matplotlib.axes import Axes, SubplotBase
88

9-
import pyretailscience.style.graph_utils as gu
9+
import pyretailscience.plots.styles.graph_utils as gu
1010
from pyretailscience.options import ColumnHelper
11-
from pyretailscience.style.graph_utils import human_format, standard_graph_styles
12-
from pyretailscience.style.tailwind import COLORS
11+
from pyretailscience.plots.styles.graph_utils import human_format, standard_graph_styles
12+
from pyretailscience.plots.styles.tailwind import COLORS
1313

1414

1515
class PurchasesPerCustomer:

0 commit comments

Comments
 (0)