DAZL Documentation | Data Analytics A-to-Z Processing Language


Contents

timeSeries

statistical primitive

slug: step-timeseries

Time Series Step

Purpose

Performs time series analysis operations on date-sequenced data, calculating moving averages and other trend indicators to reveal patterns, seasonality, and long-term trends over time.

When to Use

  • Smooth out short-term fluctuations in time-based data
  • Identify underlying trends in noisy data
  • Create comparison metrics across different time periods
  • Analyze seasonality in time series data
  • Generate predictive indicators for forecasting
  • Reduce the impact of outliers or anomalies
  • Prepare data for visualization with trend lines

How It Works

  1. Takes a dataset with a date field and specified numeric columns
  2. Sorts the data chronologically by the date field
  3. Applies requested time series operations (currently supporting moving averages)
  4. Creates new columns with calculated time series metrics
  5. Maintains the original data structure with added derived columns

Parameters

Required

  • date_field (string) - Column containing date values for sequencing
  • operations (array) - List of time series operations to perform:
    • type - Operation type (sma, ma, or moving_average for simple moving average)
    • column - Numeric column to analyze
    • period - Time window size (e.g., 7 for 7-day moving average)

Supported Operations

Simple Moving Average (SMA)

Calculates the unweighted mean of the previous n data points.

type: sma
column: revenue
period: 7

Output column named: revenue_sma_7

Input Requirements

  • Dataset must contain the specified date field
  • Date field must contain valid date values (parseable by strtotime())
  • Columns referenced in operations must contain numeric values
  • Data should ideally be at a consistent time interval (daily, weekly, etc.)

Output

Data

  • Original dataset with additional columns for each time series operation
  • New column names follow the pattern: {column}_{operation}_{period}
  • Chronological sorting by date field

Example Usage

Basic Moving Averages

timeSeries:
  date_field: transaction_date
  operations:
    - type: sma
      column: revenue
      period: 7
    - type: sma
      column: revenue
      period: 30
    - type: sma
      column: order_count
      period: 15

Example Output

Input Data

transaction_date revenue order_count
2024-09-01 1250 42
2024-09-02 980 35
2024-09-03 1340 48
2024-09-04 1100 39
2024-09-05 1420 52
2024-09-06 1580 58
2024-09-07 1050 37
2024-09-08 890 32
2024-09-09 1230 43
2024-09-10 1480 50

Output Data (With Moving Averages)

transaction_date revenue order_count revenue_sma_7 order_count_sma_15
2024-09-01 1250 42 null null
2024-09-02 980 35 null null
2024-09-03 1340 48 null null
2024-09-04 1100 39 null null
2024-09-05 1420 52 null null
2024-09-06 1580 58 null null
2024-09-07 1050 37 1245.7 null
2024-09-08 890 32 1194.3 null
2024-09-09 1230 43 1230.0 null
2024-09-10 1480 50 1250.0 null

Analytical Applications

  • Trend Identification: Longer-period moving averages reveal underlying trends
  • Seasonality Analysis: Compare multiple periods to detect cyclical patterns
  • Anomaly Detection: Identify significant deviations from moving averages
  • Forecast Foundation: Use trend data as basis for predictive models
  • Performance Benchmarking: Compare current metrics to historical averages

Future Operation Types

The time series step is designed to be extensible with additional operations:

  • Weighted moving average (WMA)
  • Exponential moving average (EMA)
  • Cumulative sum (CUMSUM)
  • Rate of change (ROC)
  • Moving standard deviation
  • Seasonal decomposition

Related Documentation

  • filter step - Pre-filter data for time series analysis
  • lag step - Create lagged variables for time series comparison
  • chart step - Visualize time series data with trend lines
  • calculate step - Create custom metrics from time series results