-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TDD Pandas - [RED/GREEN] Adding email_address column
- Loading branch information
Showing
1 changed file
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]: | ||
|
@@ -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]' | ||
] |