I am using Pandas and I need to modify some columns (product columns) which are supposed to have numbers but some of the entries are blanks or alphanumeric characters. I want to convert all non numeric entries, (including blanks, and NaN) to 0. Here is my code (I am using spyder):
Tracker = tracker_master[['Name','Month','Year','Date','Owner',
'Account_Name','Opp','Proposed_Solution',
'Product1','Product2','Product3','Product4','Product5','Signed_Date','Stage','timestamp']]
Tracker_final = Tracker[(Tracker.Year==2018) & (Tracker.Month.isin(['April','May','June','July','August'])) &
(Tracker.Stage.isin(['Inked','Approved']))]
Tracker_final[['Product1','Product2','Product3','Product4','Product5']].apply(pd.to_numeric, errors='coerce').fillna(0)
Tracker_final.to_excel(r'W:\mydrive\B\TrackerFinal.xlsx', index=False)
When I try to run this code I still get the NaN for the Product columns. What am I doing wrong?