text_html_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

recipes = pd.read_csv('/kaggle/input/foodcom-recipes-and-reviews/recipes.csv')
reviews = pd.read_csv('/kaggle/input/foodcom-recipes-and-reviews/reviews.csv')

recipes.columns

user_counts = reviews.groupby('AuthorId')['RecipeId'].nunique()

single_recipe_users = user_counts[user_counts == 1].index.tolist()

recipesidss = reviews.loc[reviews['AuthorId'].isin(single_recipe_users), 'RecipeId']

recipe_counts = reviews.loc[reviews['RecipeId'].isin(recipesidss), 'RecipeId'].value_counts()

useless_recipes = recipe_counts[recipe_counts == 1].index.tolist()

reviews = reviews[~reviews['RecipeId'].isin(useless_recipes)]

recipes = recipes[~recipes['RecipeId'].isin(useless_recipes)]

recipes.isnull().sum(axis=0)

recipesReviews = recipes.loc[recipes['RecipeId'].isin(reviews['RecipeId'].unique())]

recipesNot_in_list = reviews.loc[~reviews['RecipeId'].isin(recipes['RecipeId'])]

reviews = reviews.loc[~reviews['ReviewId'].isin(recipesNot_in_list['ReviewId'])]

reviews.isnull().sum(axis=0)

recipesReviews.nunique()

recipesReviews[recipesReviews.duplicated(subset=['Name', 'AuthorId'], keep=False)].sort_values(by='Name')

duplicates = recipesReviews[recipesReviews.duplicated(subset=['Name', 'AuthorId'], keep=False)]
dropped_duplicates_df = duplicates.drop_duplicates(subset=['Name', 'AuthorId'], keep='first')

temp2 = reviews.loc[reviews['RecipeId'].isin(duplicates['RecipeId'])]

temp2