As you might recall, there are a few things we need to clean up in this dataset. The clean-up steps are as follows:
- Handling negative quantity: There are transactions with a negative Quantity value, which represent canceled orders. We are going to ignore those canceled orders for this exercise, so we will need to exclude them from our pandas DataFrame. The code to exclude these negative values in the Quantity column looks as follows:
df = df.loc[df['Quantity'] > 0]
We are simply taking all of those rows with a positive Quantity value and storing them back to the df variable.
- Dropping NaN records: We need to drop records with no CustomerID. Since we are going to build a machine learning model to predict the 3 month customer ...