diff --git a/src/codewars/PandasTutorial.py b/src/codewars/PandasTutorial.py new file mode 100644 index 0000000..0567f8d --- /dev/null +++ b/src/codewars/PandasTutorial.py @@ -0,0 +1,20 @@ +import pandas as pd + + +def export_csv_with_name_and_grade(student_name: str, grade: str): + students_df = pd.read_csv("files/students.csv", index_col=False) + grades_df = pd.read_csv("files/grades.csv", index_col=False) + + print(students_df) + print(grades_df) + + students_grades_df = students_df.merge( + grades_df, left_on="Student_ID", right_on="ID" + ) + + solution = students_grades_df[ + (students_grades_df["Name"] == student_name) + & (students_grades_df["Grade"] == grade) + ] + + solution[["Student_ID", "Class"]].to_csv("files/output.csv", index=False)