This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mode = ''.join(df_netflix_2019['rating'].mode()) | |
| df_netflix_2019['rating'].fillna(mode, inplace=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #creating column (extract) | |
| df_movie = df_netflix_2019[df_netflix_2019['type']=='Movie'] | |
| df_movie = df_movie.assign(minute = df_movie['duration'].str.extract(r'(\d+)', expand=False).astype(int)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df_netflix_originals = pd.read_csv('netflix_originals.csv') | |
| #inconsintent column names | |
| df_netflix_originals.rename(columns={'titles':'title', 'years':'release_year'}, inplace=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df_netflix_originals['title'] = df_netflix_originals['title'].apply(lambda x:x.lower()) | |
| df_netflix_originals['title'] = df_netflix_originals['title'].str.lower() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fuzzywuzzy import process, fuzz | |
| states = ['New York', 'California', 'Washington', 'Hawaii'] | |
| df_states = pd.DataFrame({'states':['NY', 'CA', 'Washington DC', 'Hawai']}) | |
| df_states[['match', 'score']] = df_states['states'].apply(lambda x:process.extractOne(x, states, scorer=fuzz.token_sort_ratio)).apply(pd.Series) | |
| df_states |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df_netflix_originals = df_netflix_originals.astype({"release_year": int}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df_netflix_originals['title'] = df_netflix_originals['title'].apply(lambda x:x.strip()) | |
| df_netflix_originals['title'] = df_netflix_originals['title'].str.strip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # remove punctuation: clean characters other than word or spaces | |
| df_netflix_originals['title'] = df_netflix_originals['title'].apply(lambda x:re.sub('[^\w\s]','',x)) | |
| df_netflix_originals['title'].replace('[^\w\s]', '', regex=True, inplace=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df_netflix = pd.merge(df_netflix_originals, df_netflix_2019, on=['title', 'type', 'release_year'], | |
| how='outer') | |
| df_netflix['original'].fillna('Catalog', inplace=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #drop_duplicates: data duplicated because of disagreement in releaase_year | |
| df_netflix.drop_duplicates(['title'], keep='first', inplace=True) |