Pandas - Merge two or more files and create a merged one
ยท 5 min read
You've two or more files and you wish to merge them. For instance, a list of employees and their salary for 2020 up to 2024. Or a list of cost centers and their budget/expenses. Or a list of students and their evaluation score. Or ...
Let's look at an example: a list of employees and their salaries.
We've many files, one by year, with this structure:
id;first_name;last_name;salary
0;Gina;Andrade;6040
1;Adam;Rowe;3866
2;Michael;Martinez;6913
And our need is to merge yearly files and generate a merged one with employees and their salary across years so, at the end, we wish to obtain this:
id;first_name;last_name;salary_2020;salary_2021;salary_2022;salary_2023;salary_2024
0;Gina;Andrade;6040;4413;7773;6208;7363
1;Adam;Rowe;3866;3678;2726;5425;7570
2;Michael;Martinez;6913;6493;5664;4902;4657
Using Pandas will make this piece of cake...