runtime
417 / 500
question 417 pandas Foundations · medium

Clean invoice lines for a customer report

A customer report can't use invoice lines without a customer, and it shows "UNKNOWN" where a description is missing. Write customer_lines(lines): return a new DataFrame without the rows whose Customer ID is missing, and with missing Descriptions replaced by "UNKNOWN". The caller's DataFrame must keep all its rows and gaps.

Functioncustomer_lines(lines)
linesa DataFrame with Invoice, StockCode, Description, Quantity, Customer ID
Returnsa new DataFrame, same columns, rows in their original order

Loading your progress…

Clean invoice lines for a customer report — Python practice · Runtime