Recall & Review
beginner
What is a categorical data type in pandas?
A categorical data type in pandas is a special type used to represent variables that have a fixed number of possible values, called categories. It saves memory and can speed up operations compared to using plain strings.
Click to reveal answer
beginner
How does using categorical type save memory?
Categorical type stores data as integer codes internally instead of full strings. This reduces the amount of memory needed, especially when many values repeat the same categories.
Click to reveal answer
intermediate
Why can categorical data speed up some operations?
Because categorical data uses integer codes, pandas can perform comparisons and groupings faster than with strings. This makes sorting, filtering, and grouping more efficient.
Click to reveal answer
beginner
When should you use categorical data type?
Use categorical type when your data has a limited set of repeated values, like colors, categories, or labels. It helps with memory and speed, especially for large datasets.
Click to reveal answer
intermediate
Can categorical data have an order? What does it mean?
Yes, categorical data can be ordered. This means the categories have a meaningful sequence, like 'small', 'medium', 'large'. Ordered categorical data allows comparisons like greater than or less than.
Click to reveal answer
What is the main benefit of using categorical type in pandas?
✗ Incorrect
Categorical type saves memory by storing codes and speeds up operations like grouping.
How does pandas store categorical data internally?
✗ Incorrect
Pandas stores categorical data as integer codes representing categories.
When is it NOT a good idea to use categorical type?
✗ Incorrect
Categorical type is less useful if most values are unique and not repeated.
What does ordered categorical data allow you to do?
✗ Incorrect
Ordered categorical data lets you compare categories in a meaningful sequence.
Which pandas function converts a column to categorical type?
✗ Incorrect
pd.Categorical() converts data to categorical type.
Explain why using categorical data type can improve performance and memory usage in pandas.
Think about how storing repeated strings as numbers helps.
You got /4 concepts.
Describe a real-life example where converting a column to categorical type would be helpful.
Consider something like colors, days of the week, or product types.
You got /4 concepts.