train kata "Pandas Tutorial"
This commit is contained in:
parent
b11ca22119
commit
323687c00d
20
src/codewars/PandasTutorial.py
Normal file
20
src/codewars/PandasTutorial.py
Normal file
@ -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)
|
||||
Loading…
x
Reference in New Issue
Block a user