Skip to content

Instantly share code, notes, and snippets.

@thepycoach
Created December 13, 2021 17:38
Show Gist options
  • Select an option

  • Save thepycoach/da42b7807d8d3491fdd8f08be0fffeb3 to your computer and use it in GitHub Desktop.

Select an option

Save thepycoach/da42b7807d8d3491fdd8f08be0fffeb3 to your computer and use it in GitHub Desktop.
# Imported StudentsPerformance_id.csv
import pandas as pd
StudentsPerformance_id_csv = pd.read_csv(r'StudentsPerformance_id.csv')
# Imported LanguageScore.csv
import pandas as pd
LanguageScore_csv = pd.read_csv(r'LanguageScore.csv')
# Merged LanguageScore_csv and StudentsPerformance_id_csv
temp_df = StudentsPerformance_id_csv.drop_duplicates(subset='id') # Remove duplicates so lookup merge only returns first match
df3 = LanguageScore_csv.merge(temp_df, left_on=['id'], right_on=['id'], how='left', suffixes=['_LanguageScore_csv', '_StudentsPerformance_id_csv'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment