[Solved] How to create a new column with a value from another column in python

[ad_1]

You can try this:

df['newprice'] = df.groupby('type')['price'].transform('max')
df = df.drop_duplicates(subset="type", keep="first")
print(df)

Output:

      type  price  newprice
0    shoes     10        30
1  clothes     20        40

1

[ad_2]

solved How to create a new column with a value from another column in python