Skip to content

Course Notes

Use this workspace to take notes, store code snippets, and build your own interactive cheatsheet!

# Import any packages you want to use here
import pandas as pd
import numpy as np

Take Notes

Add notes here about the concepts you've learned and code cells with code you want to keep.

Add your notes here

df= df1.merge(df2, on='')
.merge(df3, on='')

#Creating filter filter_criteria= ((merged_df['month']==7) &(merged_df['day_type']=='Weekday')) #Using .loc and filter to select for rides merged_df.loc[filter_criteria, 'rides'].sum())

#agg() function count_df= df.groupby('').agg({'':"count"})

Count the number of genres

genre_count = genres_movies.groupby('genre').agg({'id':'count'}) #sort values sorted_df= count_df.sort_values('account', ascendong=False)

#When join table to itself: -Hierarchical relationship -Sequential relationship -Gra

# Add your code snippets here
# Count the number of rows in the budget column that are missing
number_of_missing_fin = movies_financials['budget'].isnull().sum()
#Join
# Merge action_movies to the scifi_movies with right join
action_scifi = action_movies.merge(scifi_movies, on='movie_id', how='right',
                                   suffixes=('_act','_sci'))

# From action_scifi, select only the rows where the genre_act column is null
scifi_only = action_scifi[action_scifi['genre_act'].isnull()]
# Merge the movies and scifi_only tables with an inner join
movies_and_scifi_only = movies.merge(scifi_only, left_on='id', right_on='movie_id')

#Outer Join
# Merge iron_1_actors to iron_2_actors on id with outer join using suffixes
iron_1_and_2 = iron_1_actors.merge(iron_2_actors,
                                     on='id',
                                     how='outer',
                                     suffixes=('_1','_2'))

# Create an index that returns true if name_1 or name_2 are null
m = ((iron_1_and_2['name_1'].isnull()) | 
     (iron_1_and_2['name_2'].isnull()))

# Print the first few rows of iron_1_and_2
print(iron_1_and_2[m].head())

Filtering Joins