rfmkit 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. rfmkit-0.1.0/.gitignore +65 -0
  2. rfmkit-0.1.0/CHANGELOG.md +29 -0
  3. rfmkit-0.1.0/LICENSE +21 -0
  4. rfmkit-0.1.0/PKG-INFO +122 -0
  5. rfmkit-0.1.0/README.md +88 -0
  6. rfmkit-0.1.0/pyproject.toml +80 -0
  7. rfmkit-0.1.0/src/rfmkit/__init__.py +22 -0
  8. rfmkit-0.1.0/src/rfmkit/_utils.py +352 -0
  9. rfmkit-0.1.0/src/rfmkit/data/orders.csv +5001 -0
  10. rfmkit-0.1.0/src/rfmkit/datasets.py +36 -0
  11. rfmkit-0.1.0/src/rfmkit/plot.py +184 -0
  12. rfmkit-0.1.0/src/rfmkit/py.typed +0 -0
  13. rfmkit-0.1.0/src/rfmkit/segment.py +225 -0
  14. rfmkit-0.1.0/src/rfmkit/table.py +476 -0
  15. rfmkit-0.1.0/tests/conftest.py +221 -0
  16. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_customer_date_default.json +84 -0
  17. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_customer_days_custom.json +84 -0
  18. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_customer_days_default.json +84 -0
  19. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_orders_custom.json +84 -0
  20. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_orders_default.json +84 -0
  21. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_orders_freq_plus.json +84 -0
  22. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_orders_later_date.json +84 -0
  23. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_orders_one_bin.json +60 -0
  24. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_orders_segments.json +164 -0
  25. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/bundle_orders_unequal.json +84 -0
  26. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_all_future_orders.json +129 -0
  27. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_analysis_date_same_day.json +159 -0
  28. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_custom_freq_1_2_3_4_5.json +206 -0
  29. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_custom_freq_2_3_4_5.json +195 -0
  30. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_custom_recency.json +179 -0
  31. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_cutpoint_1_31.json +606 -0
  32. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_duplicate_customer_ids.json +41 -0
  33. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_duplicate_order_rows.json +124 -0
  34. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_empty_input.json +26 -0
  35. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_fractional_orders.json +47 -0
  36. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_metadata_constant.json +142 -0
  37. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_metadata_na.json +45 -0
  38. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_na_revenue_auto.json +47 -0
  39. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_na_revenue_custom.json +147 -0
  40. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_negative_revenue.json +129 -0
  41. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_no_orders_na_recency.json +41 -0
  42. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_numeric_ids.json +144 -0
  43. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_one_bin.json +151 -0
  44. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_posixct_date.json +37 -0
  45. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_segments_duplicate_names.json +216 -0
  46. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_segments_inclusive.json +198 -0
  47. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_segments_na_score.json +162 -0
  48. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_segments_numeric_names.json +216 -0
  49. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_segments_others.json +216 -0
  50. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_segments_overlap.json +216 -0
  51. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_single_customer.json +115 -0
  52. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_single_order.json +174 -0
  53. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_ties_all_equal.json +179 -0
  54. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_ties_freq_quintiles.json +195 -0
  55. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_ties_ten_rows.json +259 -0
  56. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_two_bins.json +130 -0
  57. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/edge_zero_orders.json +131 -0
  58. rfmkit-0.1.0/tests/fixtures/rfmkit/cases/summary_aov_rounding.json +12018 -0
  59. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_customer_date_default.csv.gz +0 -0
  60. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_customer_date_default_threshold.csv.gz +0 -0
  61. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_customer_days_custom.csv.gz +0 -0
  62. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_customer_days_custom_threshold.csv.gz +0 -0
  63. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_customer_days_default.csv.gz +0 -0
  64. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_customer_days_default_threshold.csv.gz +0 -0
  65. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_custom.csv.gz +0 -0
  66. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_custom_threshold.csv.gz +0 -0
  67. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_default.csv.gz +0 -0
  68. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_default_threshold.csv.gz +0 -0
  69. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_freq_plus.csv.gz +0 -0
  70. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_freq_plus_threshold.csv.gz +0 -0
  71. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_later_date.csv.gz +0 -0
  72. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_later_date_threshold.csv.gz +0 -0
  73. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_one_bin.csv.gz +0 -0
  74. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_one_bin_threshold.csv.gz +0 -0
  75. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_segments.csv.gz +0 -0
  76. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_segments_threshold.csv.gz +0 -0
  77. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_unequal.csv.gz +0 -0
  78. rfmkit-0.1.0/tests/fixtures/rfmkit/data/bundle_orders_unequal_threshold.csv.gz +0 -0
  79. rfmkit-0.1.0/tests/fixtures/rfmkit/data/rfm_data_customer.csv.gz +0 -0
  80. rfmkit-0.1.0/tests/fixtures/rfmkit/data/rfm_data_orders.csv.gz +0 -0
  81. rfmkit-0.1.0/tests/fixtures/rfmkit/manifest.json +337 -0
  82. rfmkit-0.1.0/tests/fixtures/rfmkit/session-info.txt +4 -0
  83. rfmkit-0.1.0/tests/parity/test_rfm_parity.py +323 -0
  84. rfmkit-0.1.0/tests/test_datasets.py +41 -0
  85. rfmkit-0.1.0/tests/test_doctests.py +19 -0
  86. rfmkit-0.1.0/tests/test_packaging.py +34 -0
  87. rfmkit-0.1.0/tests/test_plot.py +137 -0
  88. rfmkit-0.1.0/tests/test_quirks.py +416 -0
  89. rfmkit-0.1.0/tests/test_segment.py +308 -0
  90. rfmkit-0.1.0/tests/test_validation.py +292 -0
  91. rfmkit-0.1.0/tools/build_docs_examples.py +314 -0
  92. rfmkit-0.1.0/tools/generate_orders.py +74 -0
  93. rfmkit-0.1.0/tools/rfmkit-fixtures.R +841 -0
@@ -0,0 +1,65 @@
1
+ # History files
2
+ .Rhistory
3
+ .Rapp.history
4
+
5
+ # Session Data files
6
+ .RData
7
+ .RDataTmp
8
+
9
+ # User-specific files
10
+ .Ruserdata
11
+ .Rproj.user/
12
+ .Rproj.user
13
+
14
+ # Output files from R CMD build
15
+ /*.tar.gz
16
+
17
+ # Output files from R CMD check
18
+ /*.Rcheck/
19
+
20
+ # Rcpp / C++ / object files
21
+ *.o
22
+ *.so
23
+ *.dll
24
+
25
+ # Python
26
+ __pycache__/
27
+ *.py[cod]
28
+ .pytest_cache/
29
+ .coverage
30
+ coverage.xml
31
+ htmlcov/
32
+ *.egg-info/
33
+ dist/
34
+ build/
35
+
36
+ # OS generated files
37
+ .DS_Store
38
+ .DS_Store?
39
+ ._*
40
+ .Spotlight-V100
41
+ .Trashes
42
+ ehthumbs.db
43
+ Thumbs.db
44
+
45
+ # Editor temporary files
46
+ *.swp
47
+ *.swo
48
+ *~
49
+ .vscode/
50
+ .idea/
51
+
52
+ # Internal / Private Documentation
53
+ roadmap/
54
+ roadmap_muse.md
55
+
56
+ # Scratch space for the build task
57
+ .b1-tmp/
58
+ .aud1-tmp/
59
+
60
+ # Scratch space for the audit-fix task
61
+ .fx1-tmp/
62
+
63
+ # Scratch space for the docs task and the MkDocs build output
64
+ .docs-tmp/
65
+ site/
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - First release.
6
+ - `rfm_table_order()` and `rfm_table_customer()` score customer tables with
7
+ R `rfm` 0.5.1 parity: type-7 quantiles, `findInterval`-style intervals,
8
+ right-closed automatic bins and lower-inclusive custom breaks. Ties leave
9
+ empty bins, exactly as in R.
10
+ - `RFMTable` frozen result object with `.rfm`, `.threshold`, `.analysis_date`
11
+ and the three bin specifications.
12
+ - `rfm_segment()` (first match wins, inclusive bounds, `"Others"`) and
13
+ `rfm_segment_summary()` (customers, orders, revenue, aov rounded to 2 dp).
14
+ - `rfm_plot_segment_summary()` draws a matplotlib bar chart and returns the
15
+ `Axes`; pass `ax=` to draw into your own figure.
16
+ - Bundled synthetic orders data via `rfmkit.load_orders()`.
17
+ - `rfm_score` is now an integer column: `int64` when every score is present
18
+ and pandas nullable `Int64` when any score is missing, matching the three
19
+ component score columns. The printed values are unchanged.
20
+ - Audit round 1 fixes: `aov` rounds exactly like R 4.x (the nearer two-decimal
21
+ candidate), flipped charts put their limits on the value axis, unused
22
+ categories of a categorical customer id are dropped, the customer/date path
23
+ keeps its source date column, and the release workflow runs the test suite.
24
+ `py.typed` is shipped and the licence metadata uses PEP 639.
25
+ - Deliberate differences from R `rfm` 0.5.1: whole-number bin validation,
26
+ date-time columns rejected, constant metadata with `NA` kept, empty input
27
+ returns a zero-row table, fractional counts rejected up front, int64 counts,
28
+ one-item bin lists rejected, and `rfm_segment` bounds must match
29
+ `segment_names` (R recycles length-1 bounds).
rfmkit-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rsquared Academy / Aravind Hebbali
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
rfmkit-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.5
2
+ Name: rfmkit
3
+ Version: 0.1.0
4
+ Summary: Recency, frequency and monetary (RFM) analysis in pure pandas and matplotlib.
5
+ Project-URL: Homepage, https://rfmkit.rsquaredacademy.com
6
+ Project-URL: Documentation, https://rfmkit.rsquaredacademy.com
7
+ Project-URL: Repository, https://github.com/rsquaredacademy/rfmkit
8
+ Project-URL: Issues, https://github.com/rsquaredacademy/rfmkit/issues
9
+ Author-email: Rsquared Academy <aravindhebbali@rsquaredacademy.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: customer,frequency,marketing,monetary,recency,rfm,segmentation
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: matplotlib>=3.8
22
+ Requires-Dist: numpy>=1.26
23
+ Requires-Dist: pandas>=2.2
24
+ Provides-Extra: dev
25
+ Requires-Dist: build>=1.2; extra == 'dev'
26
+ Requires-Dist: coverage[toml]>=7.5; extra == 'dev'
27
+ Requires-Dist: pytest>=8.0; extra == 'dev'
28
+ Requires-Dist: twine>=5.0; extra == 'dev'
29
+ Provides-Extra: docs
30
+ Requires-Dist: black>=24; extra == 'docs'
31
+ Requires-Dist: mkdocs-material>=9.6; extra == 'docs'
32
+ Requires-Dist: mkdocstrings[python]>=0.29; extra == 'docs'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # rfmkit
36
+
37
+ rfmkit scores customers by recency, frequency and monetary value and turns
38
+ those scores into segments, for marketing analysts and R learners who want the
39
+ same numbers as the R [`rfm`](https://rfm.rsquaredacademy.com) package in pure
40
+ pandas and matplotlib (no compiled code, so it also runs in Pyodide).
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install rfmkit
46
+ ```
47
+
48
+ Python 3.11+ with pandas 2.2+, numpy and matplotlib.
49
+
50
+ ## Example
51
+
52
+ ```python
53
+ import pandas as pd
54
+ from rfmkit import load_orders, rfm_table_order
55
+
56
+ orders = load_orders()
57
+ table = rfm_table_order(
58
+ orders,
59
+ customer_id="customer_id",
60
+ order_date="order_date",
61
+ revenue="revenue",
62
+ analysis_date=pd.Timestamp("2026-01-01"),
63
+ )
64
+
65
+ print(table.rfm.head(3).to_string(index=False))
66
+ ```
67
+
68
+ ```text
69
+ customer_id recency_days transaction_count amount recency_score frequency_score monetary_score rfm_score
70
+ C0001 293.0 5 304.19 2 3 4 234
71
+ C0002 220.0 3 138.87 3 2 2 322
72
+ C0003 261.0 2 161.62 2 1 3 213
73
+ ```
74
+
75
+ Segment the scored customers and summarise the result:
76
+
77
+ ```python
78
+ from rfmkit import rfm_segment, rfm_segment_summary
79
+
80
+ segments = rfm_segment(
81
+ table,
82
+ segment_names=["Champions"],
83
+ recency_lower=[5], recency_upper=[5],
84
+ frequency_lower=[5], frequency_upper=[5],
85
+ monetary_lower=[5], monetary_upper=[5],
86
+ )
87
+ print(rfm_segment_summary(segments))
88
+ ```
89
+
90
+ `rfmkit.datasets.load_orders()` ships a synthetic two-year order history for
91
+ 1,000 customers and 5,000 orders.
92
+
93
+ ## Differences from R
94
+
95
+ rfmkit reproduces the numbers of R `rfm` 0.5.1, including its tie handling and
96
+ binning quirks. These are the deliberate differences:
97
+
98
+ - **Whole-number bin counts.** `recency_bins=5.5` raises `ValueError`; R accepts
99
+ it and produces non-quintile cuts.
100
+ - **Date-time columns.** A date-time `order_date` or recency column raises
101
+ `TypeError` naming the column; R silently computes a huge negative recency.
102
+ - **Constant extra columns with `NA`.** An extra order column is kept when its
103
+ non-missing values are constant, even if one value is `NA`; R drops it.
104
+ - **Empty input.** Returns a zero-row table; R fails inside `findInterval`.
105
+ - **Fractional `n_transactions`.** Rejected up front with `ValueError`; R fails
106
+ at the very end.
107
+ - **Counts above `2**31 - 1`.** Kept as int64; R coerces values above the int32
108
+ range to `NA`.
109
+ - **One-item bin lists.** `frequency_bins=[5]` raises `ValueError`; it cannot
110
+ clearly mean a bin count or a break point.
111
+ - **`rfm_segment` bound lengths.** Every `*_lower`/`*_upper` argument must have
112
+ the same length as `segment_names`; a mismatch raises `ValueError` naming the
113
+ argument. R recycles length-1 bounds, so later rules can silently receive
114
+ `NA` and never match.
115
+
116
+ ## Documentation
117
+
118
+ <https://rfmkit.rsquaredacademy.com>
119
+
120
+ ## Licence
121
+
122
+ MIT.
rfmkit-0.1.0/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # rfmkit
2
+
3
+ rfmkit scores customers by recency, frequency and monetary value and turns
4
+ those scores into segments, for marketing analysts and R learners who want the
5
+ same numbers as the R [`rfm`](https://rfm.rsquaredacademy.com) package in pure
6
+ pandas and matplotlib (no compiled code, so it also runs in Pyodide).
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pip install rfmkit
12
+ ```
13
+
14
+ Python 3.11+ with pandas 2.2+, numpy and matplotlib.
15
+
16
+ ## Example
17
+
18
+ ```python
19
+ import pandas as pd
20
+ from rfmkit import load_orders, rfm_table_order
21
+
22
+ orders = load_orders()
23
+ table = rfm_table_order(
24
+ orders,
25
+ customer_id="customer_id",
26
+ order_date="order_date",
27
+ revenue="revenue",
28
+ analysis_date=pd.Timestamp("2026-01-01"),
29
+ )
30
+
31
+ print(table.rfm.head(3).to_string(index=False))
32
+ ```
33
+
34
+ ```text
35
+ customer_id recency_days transaction_count amount recency_score frequency_score monetary_score rfm_score
36
+ C0001 293.0 5 304.19 2 3 4 234
37
+ C0002 220.0 3 138.87 3 2 2 322
38
+ C0003 261.0 2 161.62 2 1 3 213
39
+ ```
40
+
41
+ Segment the scored customers and summarise the result:
42
+
43
+ ```python
44
+ from rfmkit import rfm_segment, rfm_segment_summary
45
+
46
+ segments = rfm_segment(
47
+ table,
48
+ segment_names=["Champions"],
49
+ recency_lower=[5], recency_upper=[5],
50
+ frequency_lower=[5], frequency_upper=[5],
51
+ monetary_lower=[5], monetary_upper=[5],
52
+ )
53
+ print(rfm_segment_summary(segments))
54
+ ```
55
+
56
+ `rfmkit.datasets.load_orders()` ships a synthetic two-year order history for
57
+ 1,000 customers and 5,000 orders.
58
+
59
+ ## Differences from R
60
+
61
+ rfmkit reproduces the numbers of R `rfm` 0.5.1, including its tie handling and
62
+ binning quirks. These are the deliberate differences:
63
+
64
+ - **Whole-number bin counts.** `recency_bins=5.5` raises `ValueError`; R accepts
65
+ it and produces non-quintile cuts.
66
+ - **Date-time columns.** A date-time `order_date` or recency column raises
67
+ `TypeError` naming the column; R silently computes a huge negative recency.
68
+ - **Constant extra columns with `NA`.** An extra order column is kept when its
69
+ non-missing values are constant, even if one value is `NA`; R drops it.
70
+ - **Empty input.** Returns a zero-row table; R fails inside `findInterval`.
71
+ - **Fractional `n_transactions`.** Rejected up front with `ValueError`; R fails
72
+ at the very end.
73
+ - **Counts above `2**31 - 1`.** Kept as int64; R coerces values above the int32
74
+ range to `NA`.
75
+ - **One-item bin lists.** `frequency_bins=[5]` raises `ValueError`; it cannot
76
+ clearly mean a bin count or a break point.
77
+ - **`rfm_segment` bound lengths.** Every `*_lower`/`*_upper` argument must have
78
+ the same length as `segment_names`; a mismatch raises `ValueError` naming the
79
+ argument. R recycles length-1 bounds, so later rules can silently receive
80
+ `NA` and never match.
81
+
82
+ ## Documentation
83
+
84
+ <https://rfmkit.rsquaredacademy.com>
85
+
86
+ ## Licence
87
+
88
+ MIT.
@@ -0,0 +1,80 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "rfmkit"
7
+ version = "0.1.0"
8
+ description = "Recency, frequency and monetary (RFM) analysis in pure pandas and matplotlib."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "Rsquared Academy", email = "aravindhebbali@rsquaredacademy.com" },
15
+ ]
16
+ keywords = ["rfm", "recency", "frequency", "monetary", "customer", "segmentation", "marketing"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Science/Research",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Scientific/Engineering :: Information Analysis",
25
+ ]
26
+ dependencies = [
27
+ "numpy>=1.26",
28
+ "pandas>=2.2",
29
+ "matplotlib>=3.8",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "build>=1.2",
35
+ "coverage[toml]>=7.5",
36
+ "pytest>=8.0",
37
+ "twine>=5.0",
38
+ ]
39
+ docs = [
40
+ "black>=24",
41
+ "mkdocs-material>=9.6",
42
+ "mkdocstrings[python]>=0.29",
43
+ ]
44
+
45
+ [project.urls]
46
+ Homepage = "https://rfmkit.rsquaredacademy.com"
47
+ Documentation = "https://rfmkit.rsquaredacademy.com"
48
+ Repository = "https://github.com/rsquaredacademy/rfmkit"
49
+ Issues = "https://github.com/rsquaredacademy/rfmkit/issues"
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["src/rfmkit"]
53
+ artifacts = ["src/rfmkit/py.typed"]
54
+
55
+ [tool.hatch.build.targets.sdist]
56
+ include = [
57
+ "src/rfmkit",
58
+ "tests",
59
+ "tools",
60
+ "README.md",
61
+ "LICENSE",
62
+ "CHANGELOG.md",
63
+ "pyproject.toml",
64
+ ]
65
+
66
+ [tool.pytest.ini_options]
67
+ testpaths = ["tests"]
68
+ addopts = "-ra"
69
+
70
+ [tool.coverage.run]
71
+ source = ["rfmkit"]
72
+ branch = true
73
+
74
+ [tool.coverage.report]
75
+ show_missing = true
76
+ skip_covered = false
77
+ exclude_lines = [
78
+ "pragma: no cover",
79
+ "if TYPE_CHECKING:",
80
+ ]
@@ -0,0 +1,22 @@
1
+ """rfmkit: recency, frequency and monetary analysis in pure pandas.
2
+
3
+ The public API keeps the R ``rfm`` 0.5.1 names so R and Python learners see
4
+ the same calls.
5
+ """
6
+
7
+ from .datasets import load_orders
8
+ from .plot import rfm_plot_segment_summary
9
+ from .segment import rfm_segment, rfm_segment_summary
10
+ from .table import RFMTable, rfm_table_customer, rfm_table_order
11
+
12
+ __version__ = "0.1.0"
13
+
14
+ __all__ = [
15
+ "RFMTable",
16
+ "load_orders",
17
+ "rfm_plot_segment_summary",
18
+ "rfm_segment",
19
+ "rfm_segment_summary",
20
+ "rfm_table_customer",
21
+ "rfm_table_order",
22
+ ]