Recall & Review
beginner
What does the
memory_usage() method in pandas do?It shows the amount of memory used by each column in a DataFrame or by a Series. This helps understand how much space your data takes in memory.
Click to reveal answer
intermediate
How can you get the total memory usage of a pandas DataFrame including the index?
Use
df.memory_usage(deep=True).sum(). The deep=True option counts the actual memory usage of objects like strings.Click to reveal answer
beginner
Why is it useful to analyze memory usage in pandas?
It helps you find which columns use the most memory. Then you can optimize data types or drop unnecessary columns to save memory and speed up your program.
Click to reveal answer
intermediate
What does the
deep=True parameter do in memory_usage()?It makes pandas calculate the full memory usage of object types like strings, not just the pointer size. This gives a more accurate memory size.
Click to reveal answer
intermediate
How can you reduce memory usage after analyzing it in pandas?
You can convert columns to smaller data types (like
int8 instead of int64), or convert strings to categories if they have few unique values.Click to reveal answer
Which pandas method shows memory usage of each column in a DataFrame?
✗ Incorrect
memory_usage() returns memory used by each column. info() shows summary but less detail on memory.What does setting
deep=True in memory_usage() do?✗ Incorrect
With
deep=True, pandas counts actual memory used by objects like strings, not just pointers.How do you get total memory usage of a DataFrame including index?
✗ Incorrect
Summing
memory_usage(deep=True) gives total memory including index.Why might you convert a string column to category after memory analysis?
✗ Incorrect
Categorical data uses less memory when there are few unique values.
Which data type change can reduce memory usage for integer columns?
✗ Incorrect
Using smaller integer types like
int8 reduces memory compared to int64.Explain how to check memory usage of a pandas DataFrame and why it is important.
Think about how much space your data takes and how to find it.
You got /4 concepts.
Describe two ways to reduce memory usage in pandas after analyzing it.
Focus on changing data types and removing data.
You got /3 concepts.