a python dataframe assign values to a column based on condition?

You can compare status to 'present' then get the mininum by name:

# or `all()` instead of `min()`
df['status'].eq('present').groupby(df['name']).min()

Output:

name
anthony    False
donny      False
mason       True
paul        True
Name: status, dtype: bool

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top