![]() # Concatenate the tracks, show only columns names that are in all tables Concatenate tracks_master, tracks_ride, and tracks_st, showing only columns that are in all tables.Concatenate tracks_master, tracks_ride, and tracks_st, where the index goes from 0 to n-1.Concatenate tracks_master, tracks_ride, and tracks_st, in that order, setting sort to True.The tables tracks_master, tracks_ride, and tracks_st have loaded for you. concat() method by concatenating the tables vertically together in different ways. The track info comes from their Ride The Lightning, Master Of Puppets, and St. You have been given a few tables of data with musical track info for different albums from the metal band, Metallica. Now that you’ve done both semi- and anti-joins, it’s time to move to the next topic. With some additional data manipulation, you discovered that ‘TV-shows’ is the non-musical genre that has the most top revenue-generating tracks. Nice job! In this exercise, you replicated a semi-join to filter the table of tracks by the table of invoice items to find the top revenue non-musical tracks. Print(cnt_by_gid.merge(genres, on='gid')) # Merge the genres table to cnt_by_gid on gid and print # Group the top_tracks by gid and count the tid rowsĬnt_by_gid = top_oupby(, as_index=False).agg() Top_tracks = non_mus_tcks.isin(tracks_invoices)] isin() to subset non_mus_tcks to rows with tid in tracks_invoices Tracks_invoices = non_mus_rge(top_invoices, on='tid', how='inner') # Merge the non_mus_tck and top_invoices tables on tid Merge cnt_by_gid with the genres table on gid and print the result.Group top_tracks by gid and count the tid rows.isin() to subset the rows of non_mus_tck where tid is in the tidcolumn of tracks_invoices. Merge non_mus_tcks and top_invoices on tid using an inner join.The tables non_mus_tcks, top_invoices, and genres have been loaded for you. ![]() In this exercise, you’ll use a semi-join to find the top revenue-generating non-musical tracks. Additionally, you have a table of non-musical tracks from the streaming service. ![]() You have been given a table of invoices that include top revenue-generating items. Some of the tracks that have generated the most significant amount of revenue are from TV-shows or are other non-musical audio. Anti-joins are a powerful tool to filter a main table (i.e. From that, we can see that there are five employees not supporting top customers. Print(employees.isin(srid_list)])Ġ 1 Adams Andrew General Manager 2 Edwards Nancy Sales Manager 6 Mitchell Michael IT Manager 7 King Robert IT Staff 8 Callahan Laura IT Staff output:Ġ 1 Adams Andrew General Manager 2 Edwards Nancy Sales Manager 6 Mitchell Michael IT Manager 7 King Robert IT Staff 8 Callahan Laura IT Staff You performed an anti-join by first merging the tables with a left join, selecting the ID of those employees who did not support a top customer, and then subsetting the original employee’s table. Tremblay +1 (514) 721-4711 NaN bothĤ 3 Peacock Jane Sales Support Agent. NaN NaN NaN NaN left_onlyĢ 3 Peacock Jane Sales Support Agent. NaN NaN NaN NaN left_onlyġ 2 Edwards Nancy Sales Manager. lname_y phone fax email_y _mergeĠ 1 Adams Andrew General Manager. ![]() NameError: name 'empl_cust' is not defined Print(employees.isin(srid_list)]) In :Ġ 1 Adams Andrew General Manager 2 Edwards Nancy Sales Manager 3 Peacock Jane Sales Support Agent 4 Park Margaret Sales Support Agent 5 Johnson Steve Sales Support Agent :Ġ 1 3 Luís Gonçalves +55 (12) 3923-5555 +55 (12) 3923-5566 2 5 Leonie Köhler +49 0711 2842222 NaN 3 3 François Tremblay +1 (514) 721-4711 NaN 4 4 Bjørn Hansen +47 22 44 22 22 NaN 5 4 František Wichterlová +5555 +5555 Merge employees and top_cust # Get employees not working with top customers Srid_list = empl_cust.loc = 'left_only', 'srid'] # Select the srid column where _merge is left_only
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |