Start your terminal to use beginner mode.
Scenario
A CSV file contains daily temperature readings over multiple years. You need to decompose this time-series data to analyze its underlying patterns.
Task
Write a Python script at /home/interview/decompose_timeseries.py using statsmodels that reads /home/interview/temperature_data.csv, decomposes the temperature time-series into trend, seasonal, and residual components using additive decomposition, and saves each component to separate CSV files: /home/interview/trend.csv, /home/interview/seasonal.csv, and /home/interview/residual.csv.
Note: The statsmodels module is already installed.
Example
Input (temperature_data.csv):
date,temperature
2023-01-01,8.5
2023-01-02,9.2
...
Expected outputs:
trend.csv- Long-term trend componentseasonal.csv- Repeating seasonal patternresidual.csv- Random fluctuations
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.
Instacart
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
SAP
HashiCorp
Mastercard
Intel
Visa
Tesla