Skip to content
Advertisement

Apply for loop in multiple dataframe for multiple columns?

Dataframe is like below: Where I want to change dataframes value to ‘dead’ if age is more than 100.

JavaScript

Desired outcome

JavaScript

I was trying something like this:

JavaScript

Error shown: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I am looking for a loop that works on all dataframe.

Please correct my function also for future learning :)

Advertisement

Answer

#inspired by @jib and @ravinder

JavaScript

output:

JavaScript
Advertisement