I want to change the name in the name column to default for only rows that meet a specific condition (name == None and weight == 1). As you can see weight can be 10, but I do not want to change the names for weights of 10. Here is a small example dataframe:
post name weight response
blah1 None 1 yes
blah2 None 10 no
blah3 Annie 1 yes
How can I achieve this in a simple way?
a fast, solid, robust Panda-esque solution:
df.loc[(df.name == None) & (df.weight == 1), 'name'] = 'defaut'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With