Python analysis is valuable when definitions, calculations and conclusions form a reproducible chain. A p-value, an RFM label and a chart are outputs, not proof that the business question has been answered. This guide uses a fictional community coffee subscription shop to cover A/B decisions, transaction-based segmentation and a first pandas project. All numbers are teaching examples; no customer dataset or experiment has been run for this article.
Establish an analysis contract
Separate three tasks: assessing a new subscription explanation, describing customer transaction behavior and practicing reliable data preparation. They need different evidence and inference conditions. Descriptive segments are not randomized experiments. For each task record the question, statistical unit, observation window, input revision, exclusion policy and deliverables. Analysis must not automatically trigger marketing or change customer treatment.
Distinguish customer_id, order_id, paid_at, amount, currency and status in transaction data, with separate assignment and event records for the experiment. Item lines, orders, users and sessions are different units. Preserve raw inputs, document sanitization and field meaning, and write derived tables separately. Give the agent an explicit data scope rather than assuming it may upload customer details or contact people.
Exploratory Data Analysis fits the bounded quality checkpoint for authorized local CSV, TSV or JSON: missingness, unusual values, distributions and duplicate candidates. It needs the appropriate Python environment, format dependencies, data root and output scope. It does not silently clean and overwrite raw files, support every format, certify randomization or establish confirmatory and causal conclusions.
Scenario one: decide how to judge the experiment before launch
Define the randomization unit, primary metric, denominator, allocation ratio and observation period. In the example, randomize users and measure whether each completes a first subscription within a fixed window. Guardrails may include cancellation, complaints and page failures. Repeated visits retain the same assignment; they are not extra independent users. Specify eligibility and the start of measurement instead of comparing only people who reached a purchase page after assignment.
Plan sample size before launch using baseline conversion, a minimum effect worth detecting, significance level, target power, allocation ratio and design assumptions. Distinguish relative percentage lift from percentage-point change. A statistical library can solve a supported calculation, but the effect definition, test family and independence assumptions must match the experiment. Do not borrow a number from another design. Follow an agreed fixed-horizon decision or an appropriate sequential design rather than stopping on the first daily significant result.
Before interpreting outcomes, audit assignment, exposure and recording: observed allocation versus plan, cross-group users, missing devices, consistent eligibility filters and complete observation periods. Unexpected allocation can signal an implementation or logging defect that a different statistical test cannot repair. Record novelty, holidays and concurrent campaigns as interpretation limits. Multiple metrics, variants and repeated subgroup searches need a planned comparison policy.
Report group counts, conversion rates, absolute and relative differences, an appropriate confidence interval and test assumptions. A p-value is not the probability that the null hypothesis is true and does not measure effect magnitude. Passing a threshold does not establish business value. A nonsignificant result does not prove equivalence; examine whether its interval still contains worthwhile improvement or harm. Do not substitute observed-effect post-hoc power for interval interpretation or lower the threshold after seeing the result.
Worked example: distinguish arithmetic lift from an experiment conclusion
Suppose 500 of 10,000 users buy in group A and 520 of 10,000 buy in B. Rates are 5% and 5.2%, an absolute difference of 0.2 percentage points and a relative difference of 4%. Those are illustrative calculations, not a significance result already computed here. Audit allocation and timing, then use an appropriate method to quantify uncertainty. “520 is greater than 500” does not establish an effective new page.
Discuss the result against pre-agreed business thresholds and guardrails. Do not expand directly when uncertainty still allows meaningful harm. When data are valid but inconclusive, report that uncertainty rather than repeatedly adding observations until a threshold passes. A new experiment needs a new design and stopping policy. Deliver code, parameters, input revision, interval and limitations so the responsible team can decide; the agent does not announce a rollout on its behalf.
Scenario two: define eligible transactions before RFM scores
Recency is time since the latest eligible transaction; frequency counts eligible orders within a window; monetary value follows a declared amount definition. Fix the snapshot date and window. Specify canceled orders, refunds, tax, shipping, test orders and currency treatment. Use only information available at the snapshot, avoiding future transactions in historical segments. Keep new registrants with no purchase separate instead of making zero recency look like a recent transaction.
Aggregate item lines to orders first, confirming that order totals have not been repeated on every line. Frequency generally counts distinct eligible orders, not item rows. Use consistent timezone conventions for the latest transaction and snapshot. Define gross or net monetary value consistently; do not silently discard refund-related negative values. Analyze currencies separately until an authorized conversion rule, source and date are available.
Scores can use business thresholds or quantiles, with explicit handling for many ties, small samples and seasonality. Lower recency usually means a more recent transaction, so its scoring direction differs from increasing frequency and monetary value. A fixed five-point scheme or eight-segment scheme is not universal. Have operations review definitions, group sizes and boundary examples. “Needs attention” is a behavioral label, not a confirmed prediction of churn.
Customer A purchased once ten days ago; customer B purchased six times but last bought one hundred days ago. Total spending alone cannot tell you which needs retention support. Interpret the window, order value, refunds and channel. Produce distributions and reviewed examples before suggesting actions. Do not send coupons without authorization. Evaluate a proposed segment-based campaign separately; RFM itself does not prove that marketing works.
Scenario three: complete a small pandas project before scaling
Start with a small sanitized CSV and inspect column names, types and row count. Read identifiers with possible leading zeros as strings. Isolate date parsing failures and treat missing values according to field meaning rather than filling every column with zero. Check amount units and currency, preserving original strings for audit. For each transformation record row count, missing values, unique orders and amount reconciliation.
Before joining order and customer tables, check key uniqueness and the expected relationship. pandas merge supports validate for cardinality checks and indicator for match status. These can expose unexpected many-to-many joins and unmatched rows, but do not establish that the keys have correct business meaning. Reconcile counts and totals after joining. Handle missing keys deliberately rather than allowing null matches or duplicate keys to inflate output. Choose the join according to the question instead of universally using an inner join and silently dropping people.
The BSD-3-Clause pandas project provides maintained reading, conversion, grouping and merging capabilities worth reusing instead of implementing a new table engine. Pin the actual environment and consult its matching documentation. NumPy can support array calculations and Matplotlib basic plots, but a beginner should first reconcile tables before pursuing elaborate visuals. This article has not installed dependencies or executed a script.
A bounded agent task is: “Read only the three named sanitized CSV files under data/input. Report schema and anomalies before transformation and preserve inputs. Use analysis-plan-v1 to create order-level and customer-level tables, with reconciliation checks and a rerunnable script. Stop the affected calculation on unknown currency, date failures or unexpected key relationships. Do not contact customers or upload raw records.” Verify the workflow on a fixture small enough to count manually before expanding it.
Deliver the input manifest, cleaning code, derived tables, anomaly log, RFM definitions, experiment design and interpretation report. Label chart units, windows and sample coverage; avoid axes that exaggerate a small improvement. Reproduce the result in a documented environment and distinguish executed steps from unrun proposals. Code that appears reasonable and output that has been reviewed are different states.
Troubleshooting and FAQ
Does nonsignificance simply mean more samples are needed? Check design and data quality first; the interval and pre-agreed business threshold are more informative than “wait longer.” Does significance imply value? Consider magnitude, cost and guardrails; a tiny gain may not justify implementation. Is there one required sample size? No: baseline, target effect and design determine the calculation, with parameters recorded before launch.
Can spending totals alone support full RFM? They cannot provide recency and frequency without transaction times and order definitions. What if quantile boundaries repeat? Inspect ties and revise the documented scheme rather than randomly inventing distinctions. Why did the amount double after cleaning? Check line aggregation, duplicate imports and join cardinality before deleting records to force reconciliation. How should a beginner practice? Hand-calculate expectations for a dozen records and compare every script stage against them.
Why not associate all six source-article names? Names, download figures and security-review claims do not replace verification of a SkillPI source and matching purpose. This guide links verified EDA only at the data-quality checkpoint, not as an A/B or RFM engine. When new catalog candidates appear, test their definitions, dependencies, license and outputs against the same sanitized fixture before adding a step-specific link. Every conclusion still needs its source, method and uncertainty; installing a Skill does not transfer analytical responsibility.