Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. data = [['1020',12000,100,1.5],
  2. ['1020',15000,120,0.9],
  3. ['1020',13000,90,0.8],
  4. ['1020',10000,110,1],
  5. ['1030',5000,150,1.2],
  6. ['1030',8000,160,1.4],
  7. ['1030',7000,140,1.1],
  8. ['1000',20000,160,1.4],
  9. ['1000',40000,140,1.1],
  10. ]
  11. df = pd.DataFrame(data, columns = ['Group_Id',
  12. 'Price','Height','Distance'])
  13.  
  14. # print dataframe.
  15. df
  16.  
  17. dist = df.groupby('Group_Id')['Price'].transform('max')
  18. df['Price_score'] = dist.sub(df['Price']).div(dist)
  19. df.head(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement