From 323687c00debb0b8637a1c40a401c54c4819729a Mon Sep 17 00:00:00 2001 From: schaermicha1 Date: Fri, 13 Mar 2026 19:32:01 +0100 Subject: [PATCH] train kata "Pandas Tutorial" --- src/codewars/PandasTutorial.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/codewars/PandasTutorial.py 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)