this is the code used for creating the df:
team = np.array(['Ferrari', 'Ferrari', 'Ferrari', 'Ferrari', 'Ferrari', 'Ferrari', 'Ferrari', 'Ferrari'])
year = np.array([2019, 2019, 2019, 2020, 2020, 2020, 2020, 2020])
roundn = np.array([4, 5, 6, 1, 2, 3, 4, 5])
points = np.array([6, 10, 14, 20, 40, 60, 80, 100])
df = pd.DataFrame(team, columns=["team"])
df['year'] = year
df['roundn'] = roundn
df['points'] = points
df = df.groupby(["team", 'year']).apply(display)
So for every group I would like to add the new column that for the minimum value of the roundn column is 1 and else is 0.
I tried something like this but it does not work:
df['new_col'] = np.where(np.argmin(df['roundn']), 1, 0)
Do you have any ideas how to make it work? Thank you in advance.