I have a pandas data frame that looks something like this:
df = pd.DataFrame( [ ['A','one',7], ['A','two',8], ['B','one',9], ['B','two',6]], columns=['ID', 'Type', 'Price'])
ID Type Price
0 A one 7
1 A two 8
2 B one 9
3 B two 6
I want to add a column that's the result of comparing 'Price' among each ID. So the result looks like this:
ID Type Price Level
0 A one 7 low
1 A two 8 high
2 B one 9 high
3 B two 6 low
I'm looking for an efficient way to do this. Thanks!