The closest I've found to an answer is this: Update a dataframe in pandas while iterating row by row
However, it doesn't answer my question. Here's what I want to do:
#for each dataframe row
# if it matches criteria a, b, and c
# update two column d and e with new values
Here's a contrived dataframe example called df:
first_name last_name city state number_of_cousins number_of_siblings
0 Margaret Smith C C 0 0
1 April Smith C D 0 0
2 June Smith C C 0 0
3 David Smith A D 0 0
I need to get rows 0 and 2 to have 2 cousins and 3 siblings.
cousins_and_siblings = [2,3]
I know I'll need to use .iterrows() but besides that I haven't been able to find an example.