A left outer join enriches a primary dataset with matching fields from another dataset while retaining every row from the primary, or left, side. Where no match exists, the added fields remain missing. It is useful when purchase records must stay complete even though some customer IDs are absent from a CRM export. section 3.4.2
Enriching purchase customers from CRM
Merge extracted purchase customers with CRM records on customer_id using a left join. The resulting rows retain purchase-derived customer records, add CRM names, postcodes, and ages where available, and expose unmatched records through missing CRM columns. Inspect those missing values before copying CRM details into the consolidated customer fields. section 3.4.2
sales_and_crm_customers = sales_customers.merge(crm,
on="customer_id", how="left", suffixes=("_sales", "_crm"))
print(len(sales_and_crm_customers))
sales_and_crm_customers.isnull().sum()
The merge specifies customer_id as the key, how="left" to preserve sales_customers rows, and descriptive suffixes for overlapping columns. section 3.4.2
Practical checks after joining include:
- Count missing fields from the added dataset to estimate how many left-side records matched. section 3.4.2
- Use explicit suffixes for shared column names, then select matched rows before replacing or retaining source values. section 3.4.2
- Track source-presence flags so consolidated records still show whether CRM data was found. section 3.4.2





