python
15 lines · 1 tab
Dr. Elena Vasquez
Apr 2026
1 tab
import pandas as pd
from statsmodels.tsa.statespace.sarimax import SARIMAX
df = pd.read_csv('daily_revenue.csv', parse_dates=['date']).set_index('date')
model = SARIMAX(
df['revenue'],
order=(1, 1, 1),
seasonal_order=(1, 1, 1, 7),
enforce_stationarity=False,
enforce_invertibility=False,
)
result = model.fit(disp=False)
forecast = result.get_forecast(steps=14)
print(forecast.predicted_mean)
1 file · python
Explain with highlit
For many business forecasting tasks, a carefully tuned statistical baseline is still the right first step. SARIMAX makes seasonality, trend, and external regressors explicit, which is useful when stakeholders want understandable drivers. I use it before escalating to more opaque sequence models.
Related snips
python
import pandas as pd
df = pd.read_csv('traffic.csv', parse_dates=['timestamp'])
df['timestamp'] = pd.to_datetime(df['timestamp'], utc=True)
df = df.set_index('timestamp').sort_index()
Time series resampling and rolling windows in pandas
pandas
time-series
resampling
by Dr. Elena Vasquez
1 tab
sql
-- PostgreSQL Declarative Partitioning (10+)
-- Create partitioned table by date range
CREATE TABLE measurements (
id BIGSERIAL,
sensor_id INT NOT NULL,
Table partitioning for large datasets
database
partitioning
postgresql
by Maria Garcia
2 tabs
python
import threading
class MinuteRingBuffer:
def __init__(self, window_minutes=15):
if window_minutes < 1:
Rolling Per-Minute Log Aggregation with a Ring Buffer
logging
metrics
observability
by codesnips
3 tabs
sql
-- Install TimescaleDB extension
CREATE EXTENSION IF NOT EXISTS timescaledb;
-- Create regular table
CREATE TABLE sensor_data (
time TIMESTAMPTZ NOT NULL,
Time-series data and TimescaleDB optimization
time-series
timescaledb
postgresql
by Maria Garcia
2 tabs
Share this code
Here's the card — post it anywhere.