Given two pandas DataFrames, df_employee and df_department, write code to join them on the employee ID, select the default columns, and write the resulting DataFrame back to a file.
1Times asked
Jul 2026Last seen
Jul 2026First seen
π‘ Model Answer
python
import pandas as pd
# Assume df_employee and df_department are already loaded
# Join on employee_id
result = pd.merge(df_employee, df_department, on='employee_id', how='inner')
# Write to CSV
result.to_csv('employee_department.csv', index=False)This performs an inner join in O(n+m) time, where n and m are the row counts of the two DataFrames.
This answer was generated by AI for study purposes. Use it as a starting point β personalize it with your own experience.
π€ Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI β Starts at βΉ500