शुरू करेंमुफ़्त में शुरू करें

एक सेमी जॉइन करना

सबसे ज़्यादा रेवेन्यू लाने वाले कुछ ट्रैक्स TV-shows से हैं या फिर अन्य non-musical ऑडियो हैं। आपको invoices की एक टेबल दी गई है जिसमें top revenue-generating items शामिल हैं। इसके अलावा, आपके पास स्ट्रीमिंग सर्विस से non-musical ट्रैक्स की एक टेबल भी है। इस अभ्यास में, आप एक सेमी जॉइन का उपयोग करके top revenue-generating non-musical ट्रैक्स ढूँढेंगे.

टेबल्स non_mus_tcks, top_invoices, और genres आपके लिए लोड कर दी गई हैं.

यह अभ्यास पाठ्यक्रम का हिस्सा है

pandas के साथ Data Joining

पाठ्यक्रम देखें

अभ्यास निर्देश

  • non_mus_tcks और top_invoices को tid पर inner join से merge करें। नतीजा tracks_invoices के रूप में सेव करें.
  • .isin() का उपयोग करके non_mus_tcks की वे पंक्तियाँ चुनें जहाँ tid, tracks_invoices की tid कॉलम में हो। नतीजा top_tracks के रूप में सेव करें.
  • top_tracks को gid के आधार पर group करें और tid पंक्तियों की गिनती करें। नतीजा cnt_by_gid में सेव करें.
  • cnt_by_gid को genres टेबल के साथ gid पर merge करें और नतीजा प्रिंट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Merge the non_mus_tcks and top_invoices tables on tid
tracks_invoices = ____.merge(____)

# Use .isin() to subset non_mus_tcks to rows with tid in tracks_invoices
top_tracks = _____[non_mus_tcks['tid'].isin(____)]

# Group the top_tracks by gid and count the tid rows
cnt_by_gid = top_tracks.groupby(['gid'], as_index=False).agg({'tid':____})

# Merge the genres table to cnt_by_gid on gid and print
print(____)
कोड संपादित करें और चलाएँ