डुप्लिकेट्स हटाना
सटीक काउंट पाने के लिए डुप्लिकेट्स हटाना एक ज़रूरी स्किल है, क्योंकि अक्सर आप उसी चीज़ को कई बार गिनना नहीं चाहते. इस अभ्यास में, आप sales से यूनिक वैल्यूज़ लेकर कुछ नए DataFrames बनाएँगे.
sales उपलब्ध है और pandas को pd के रूप में इम्पोर्ट किया गया है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
pandas के साथ Data Manipulation
अभ्यास निर्देश
salesकी उन पंक्तियों को हटाइए जिनमेंstoreऔरtypeकी जोड़ी डुप्लिकेट है, उसेstore_typesके रूप में सेव कीजिए और उसका head प्रिंट कीजिए.salesकी उन पंक्तियों को हटाइए जिनमेंstoreऔरdepartmentकी जोड़ी डुप्लिकेट है, उसेstore_deptsके रूप में सेव कीजिए और उसका head प्रिंट कीजिए.is_holidayकॉलम का उपयोग करके वे पंक्तियाँ चुनिए जो holiday weeks हैं, और डुप्लिकेटdateहटाइए, इसेholiday_datesके रूप में सेव कीजिए.holiday_datesकेdateकॉलम को सेलेक्ट कीजिए और प्रिंट कीजिए.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Drop duplicate store/type combinations
store_types = ____
print(store_types.head())
# Drop duplicate store/department combinations
store_depts = ____
print(store_depts.head())
# Subset the rows where is_holiday is True and drop duplicate dates
holiday_dates = sales[sales[____]].drop_duplicates(____)
# Print date col of holiday_dates
print(____)