I want to convert the type of a column to int using pandas. Here's the source code:
# CustomerID is missing on several rows. Drop these rows and encode customer IDs as Integers.
cleaned_data = retail_data.loc[pd.isnull(retail_data.CustomerID) == False]
cleaned_data['CustomerID'] = cleaned_data.CustomerID.astype(int)
This raises the warning below:
SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
How can I avoid this warning? Is there a better way to convert the type of CustomerID to int? I'm on python 3.5.