I have this sample data set:
df_samp = pd.DataFrame({'Name': ['Bob', 'John', 'Ross'], 'Counts': [5, 4, 3]})
I want to evaluate if the Counts
column is less than 5, by row, and then add a new column showing how MUCH each specific row is less than 5. E.g.,
Name Counts Difference
Bob 5 0
John 4 1
Ross 3 2
The below is simple, but returns the standard (and expected) True
or False
:
df_samp['Counts'] = df_samp['Counts'] < 5
Name Counts
Bob False
John True
Ross True
How do I take this a step further?