# 6.3 Sorting आणि top-N rows

Source: https://ravindrabagale.com/mr/datascience/ch06-selecting-filtering-and-sorting/6-3-sorting-and-top-n.html
Language: mr (Marathi with English technical terms)

Amount उतरत्या क्रमाने, city आणि amount दोन्हींनुसार, किंवा फक्त वरच्या तीन rows अशा वेगवेगळ्या पद्धती वापरता येतात:

df.sort_values("amount", ascending=False)
df.sort_values(["city", "amount"], ascending=[True, False])
df.nlargest(3, "amount")
df.nsmallest(3, "delivery_mins")

काल्पनिक उदाहरण: Amir delivery_mins ascending sort करून सर्वात fast trips पाहतो. Pune मधल्या Shahrukh ची 8 minutes ची trip सर्वात आधी येते; ही शिकण्यासाठीची नोंद आहे.

Practice

Cancelled आणि Returned rows amount descending क्रमाने दाखवा. मग Delivered rows मधल्या top 3 amounts साठी nlargest वापरा.

Recap

Selection साठी [] / loc / iloc.

& | सोबत प्रत्येक condition parentheses मध्ये.

isin, between, sort_values आणि nlargest वापरून योग्य rows शोधा.

पुढे GroupBy आणि aggregations करूया.

रवींद्र बागले यांची tip

Top 3 Delivered हवे असतील तर आधी Delivered filter करा आणि मग nlargest वापरा. क्रम बदलला तर प्रश्नाचं उत्तर बदलू शकतं.
