Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = [['1020',12000,100,1.5],
- ['1020',15000,120,0.9],
- ['1020',13000,90,0.8],
- ['1020',10000,110,1],
- ['1030',5000,150,1.2],
- ['1030',8000,160,1.4],
- ['1030',7000,140,1.1],
- ['1000',20000,160,1.4],
- ['1000',40000,140,1.1],
- ]
- df = pd.DataFrame(data, columns = ['Group_Id',
- 'Price','Height','Distance'])
- # print dataframe.
- df
- dist = df.groupby('Group_Id')['Price'].transform('max')
- df['Price_score'] = dist.sub(df['Price']).div(dist)
- df.head(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement