Skip to content
Advertisement

How to apply function for only special cells in column pandas?

I have a issue with applying function for column in pandas, please see below code :

JavaScript

my df now show like below:

JavaScript

I would like to apply function checknum for 2 cell in column ‘new’ which is having ‘None’ value. Can someone assist this ? Thank you

Advertisement

Answer

IIUC, you can use vectorial code:

JavaScript

output:

JavaScript

That said, for the sake of the argument, your 2 functions could be combined into one:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement