Skip to content

ntpstats.adapters

Optional adapters: pandas, xarray and Parquet/Arrow (no hard dependencies).

  • :func:to_pandas / :func:from_pandas: a :class:TimeSeries as a DataFrame with a UTC DatetimeIndex (offset plus the extra columns; name, format and metadata in df.attrs).
  • :func:stability_to_dataframe: one row per tau with the deviation, its interval, EDF, noise type and number of terms.
  • :func:dynamic_to_xarray: sliding-window stability as a (time, tau) DataArray.
  • :func:write_parquet / :func:read_parquet: columnar files that keep float64 precision and the series metadata (Arrow schema metadata). Parquet files are auto-detected by every command.

Install what you need: pip install pandas, xarray or pyarrow (pip install 'ntpstats[data]' installs all three).

to_pandas(series)

DataFrame indexed by UTC time (ns precision) with offset and the extra columns.

from_pandas(df, offset='offset', time=None, name=None, negate=False)

A :class:TimeSeries from a DataFrame.

Time comes from a DatetimeIndex (naive times are taken as UTC) or the time column (datetimes, or numbers as POSIX seconds). offset is the column holding reference - local in seconds (negate for local - reference); every other numeric column becomes an extra column.

stability_to_dataframe(result)

One row per tau: tau, dev, lo, hi, edf, alpha, noise, n (attrs: kind, tau0, ci).

dynamic_to_xarray(dyn)

Sliding-window stability as an xarray DataArray with dims (time, tau).

write_parquet(series, path, compression='zstd')

Write one series as Parquet (float64 columns, metadata kept).

read_parquet(source, name=None)

Read a Parquet file written by :func:write_parquet (or any table with unix_time/offset).