how to show which item is placed with the most quantity from this data?
how to show which item is most ordered groupby choice_description?
JavaScript
x
3
1
url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv'
2
df= pd.read_csv(url, sep = 't')
3
My data
JavaScript
1
11
11
1
order_id quantity item_name choice_description item_price
2
1 1 Chips and Fresh Tomato Salsa NULL $2.39
3
1 1 Nantucket Nectar [Apple] $3.39
4
2 2 Chicken Bowl [Tomatillo-Red Chili Salsa (Hot), [Black Beans, Rice, Cheese, Sour Cream]] $16.98
5
3 1 Chicken Bowl [Fresh Tomato Salsa (Mild), [Rice, Cheese, Sour Cream, Guacamole, Lettuce]] $10.98
6
3 1 Side of Chips NULL $1.69
7
4 1 Steak Burrito [Tomatillo Red Chili Salsa, [Fajita Vegetables, Black Beans, Pinto Beans, Cheese, Sour Cream, Guacamole, Lettuce]] $11.75
8
4 1 Steak Soft Tacos [Tomatillo Green Chili Salsa, [Pinto Beans, Cheese, Sour Cream, Lettuce]] $9.25
9
10
11
Advertisement
Answer
This will list all ties (if any).
JavaScript
1
2
1
df.loc[df["quantity"] == df["quantity"].max(), "item_name"]
2
Output:
JavaScript
1
3
1
3598 Chips and Fresh Tomato Salsa
2
Name: item_name, dtype: object
3