Each run starts with fresh data. Download any exported files before another run. Your written answers and code drafts are saved on this device; export your work to keep a backup.
M12C01 · Explore · predict · practice
Clean spaces and preserve meaningful labels
The .str accessor applies text operations to each entry in a Series. strip() removes spaces at the beginning and end. A label map can then standardize spelling while preserving the exact labels you want.
Watch for this. An unrecognized value passed through a dictionary map becomes missing; inspect unmatched labels.
Your turn
Standardize all Campus labels as exactly RAK or Dubai. Handle case and surrounding spaces before mapping. Store Student_ID and the cleaned Campus for every source row in result.
For the code check, keep these result variable names: result. Different valid approaches are welcome.
Show a hint
Use .str.strip().str.lower() followed by .map({"rak": "RAK", "dubai": "Dubai"}).
S002 changes from dubai to Dubai. The abbreviation RAK remains uppercase.
Compare your explanations
Read. Leading and trailing whitespace from each text value.
Predict. Amira, without the surrounding spaces.
Explain. No. Internal spaces are preserved.
One quick check
Would .str.title() alone preserve RAK exactly?
What you should be able to explain. Standardize categories without destroying their meaning.
M12C02 · Explore · predict · practice
Literal text and regular expressions
str.contains() checks whether text contains a pattern. Use regex=False when you want the characters literally. With a regular expression, characters such as a dot can have special meanings.
Both report.csv and reportXcsv begin with report. Their extensions do not matter for this question.
Compare your explanations
Read. The dot should be an actual dot, not a pattern matching any character.
Predict. report.csv and notes.csv.
Explain. It treats a missing text entry as not matching the search.
One quick check
Which argument makes a search literal?
What you should be able to explain. Choose text-search semantics deliberately.
M12C03 · Explore · predict · practice
Split a value into separate columns
str.split() separates text at a delimiter. expand=True creates separate columns rather than a list in each cell. Limiting splits can protect the rest of a string when a delimiter appears repeatedly.
example.edu has two known occurrences. Missing domains are excluded by value_counts() by default.
Compare your explanations
Read. The @ character.
Predict. amira.
Explain. We want two table columns, so each piece can be selected and analyzed separately.
One quick check
What object does expand=True produce here?
What you should be able to explain. Split text into fields before summarizing its parts.
M12C04 · Explore · predict · practice
Extract only values that match a structure
str.extract() uses capture groups to pull parts out of a matching pattern. Named groups become useful column names. A nonmatching string produces missing fields, which you should inspect.