Modify Some Columns Of A Dataframe With Pandas
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 co
Solution 1:
It appears you just need to assign back to a sub-dataframe of your selected columns:
cols = ['Product'+str(i) for i inrange(1, 6)]
Tracker_final[cols] = Tracker_final[cols].apply(pd.to_numeric, errors='coerce').fillna(0)
If this does not work, please update your question to include sample data which replicates your problem.
Post a Comment for "Modify Some Columns Of A Dataframe With Pandas"