इंडेक्स वैल्यूज़ के अनुसार सॉर्ट करना
पहले, आपने .sort_values() कॉल करके DataFrame की पंक्तियों का क्रम बदला था. इंडेक्स के एलिमेंट्स के आधार पर सॉर्ट करना भी उपयोगी है. इसके लिए, आपको .sort_index() का उपयोग करना होगा.
pandas को pd के रूप में लोड किया गया है. temperatures_ind में country और city का मल्टी-लेवल इंडेक्स है, और यह उपलब्ध है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
pandas के साथ Data Manipulation
अभ्यास निर्देश
temperatures_indको इंडेक्स वैल्यूज़ के अनुसार सॉर्ट करें.temperatures_indको"city"लेवल पर इंडेक्स वैल्यूज़ के अनुसार सॉर्ट करें.temperatures_indको पहले country बढ़ते क्रम (ascending) में, फिर city घटते क्रम (descending) में सॉर्ट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Sort temperatures_ind by index values
print(____)
# Sort temperatures_ind by index values at the city level
print(____)
# Sort temperatures_ind by country then descending city
print(____)