Data Types and Column Roles
Unit ID: ML-M02-U02 Estimated active time: 25-30 minutes
Type is not the same as role
A column has a data type, such as text, number, date, or category.
A column also has a role, such as target, feature, metadata, or excluded.
These are different questions.
For example, final_quiz_score is numeric. But it is not a valid feature for a day-3 prediction because it is recorded later.
Common ML column types
| Type | Example | Note |
|---|---|---|
| Numeric | day3_minutes_active | May need missing-value handling |
| Categorical | python_preparation | May need encoding later |
| Date/time | started_module1_date | Useful for timing checks |
| Binary | completed_module1_by_day10 | Often a target |
| Identifier | record_id | Usually metadata, not a feature |
Inspect with pandas
Use:
df.info()
df.head()
df.dtypes
These commands do not tell you everything, but they help you start.
object columns in pandas often contain text or categories. You must inspect the values before deciding how to use them.
Practice
For each column in the Module 2 dataset, fill:
| Column | Type | Role |
|---|---|---|
record_id | text | metadata |
completed_module1_by_day10 | binary | target |
final_quiz_score | numeric | exclude future information |
Then complete the remaining columns.
Takeaway
Column type tells you what kind of value is stored. Column role tells you how the value may be used. A numeric column can still be unsafe for modelling.
