Skip to content

Commit

Permalink
TDD Pandas - [RED/GREEN] Adding email_address column
Browse files Browse the repository at this point in the history
  • Loading branch information
diligejy committed Jan 20, 2024
1 parent 72b8c01 commit fd4d58c
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions PyCon_PL/Test_Driven_Pandas/tests/test_gradebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def _create_group(raw_students_group:pd.DataFrame) -> pd.DataFrame:
result = pd.DataFrame()
return result.assign(
net_id = raw_students_group["NetID"].str.lower(),
email_address = raw_students_group['Email Address'].str.lower(),
)

def generate_gradebook(students_df:pd.DataFrame) -> dict[int, pd.DataFrame]:
Expand Down Expand Up @@ -51,19 +52,45 @@ def test_results_group_contains_students_net_id_lowercase():
"ID": 1,
"Name": "Doe, John",
"NetID": "JXD12345",
"Email Adress": "[email protected]",
"Email Address": "[email protected]",
"Group": 1,
},
{
"ID": 2,
"Name": "Doe, Second",
"NetID": "SXD54321",
"Email Adress": "[email protected]",
"Email Address": "[email protected]",
"Group": 1,
},
]
students_df = pd.DataFrame(data=students).set_index("ID")

result = generate_gradebook(students_df=students_df)

assert result[1]["net_id"].to_list() == ["jxd12345", "sxd54321"]
assert result[1]["net_id"].to_list() == ["jxd12345", "sxd54321"]

def test_results_group_contains_students_email_address_lowercase():
students = [
{
"ID": 1,
"Name": "Doe, John",
"NetID": "JXD12345",
"Email Address": "[email protected]",
"Group": 1,
},
{
"ID": 2,
"Name": "Doe, Second",
"NetID": "SXD54321",
"Email Address": "[email protected]",
"Group": 1,
},
]
students_df = pd.DataFrame(data=students).set_index("ID")

result = generate_gradebook(students_df = students_df)

assert result[1]['email_address'].to_list() == [
'[email protected]',
'[email protected]'
]

0 comments on commit fd4d58c

Please sign in to comment.