81. Analyze DataFrame Memory Usage
Beginner Mode
Start your terminal to use beginner mode.
Scenario
A large dataset needs memory analysis to understand which columns consume the most memory and identify optimization opportunities.
Task
Write a Python script at /home/interview/analyze_memory.py using pandas that reads /home/interview/sales_data.csv, calculates the memory usage of each column in megabytes (rounded to 2 decimal places), and saves the report to /home/interview/memory_report.csv.
Note: pandas is already installed.
Example
Expected output format in /home/interview/memory_report.csv:
column_name,memory_mb
product_name,2.15
customer_email,1.83
quantity,0.08
order_date,0.08
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Essential
SQL 0/33
Spark 0/20
Snowflake 0/22
Python 0/24
Need more practice in this area? Explore more questions →
SAP
Revolut
Accenture
Adobe
Google
LinkedIn
Samsung
Datadog
Wix
Dropbox
Meta
OpenAI
Hulu
Uber
X
DoorDash
Anthropic
Amazon
ActivisionBlizzard
Vercel
Crypto.Com
Zscaler
DeutscheBank
Apple
GoDaddy
GitLab
BMW
PayPal
Snowflake
AMD
Twilio
Atlassian
JPMorgan
NVIDIA
IBM
Databricks
Coinbase
Cisco
Robinhood
Twitter
Microsoft
Palantir
Netflix
VMware
Cloudflare
Stripe
Lyft
Salesforce
GitHub
Bloomberg
Airbnb
Walmart
HashiCorp
Instacart
Mastercard
Intel
Visa
Tesla