tsfeatures
raw JSON → 0.4.5 verified Fri May 01 auth: no python
Calculates various features from time series data, including autocorrelation, entropy, seasonality, stationarity, and trend-based metrics. Designed for time series classification and preprocessing. Current stable version is 0.4.5. Release cadence is irregular based on fixes and feature additions.
pip install tsfeatures Common errors
error AttributeError: module 'tsfeatures' has no attribute 'calculate_features' ↓
cause Using outdated function-based API; current library requires class instantiation.
fix
Change to:
from tsfeatures import Tsfeatures; tf = Tsfeatures(); features = tf.calculate_features(df) error ValueError: The 'freq' argument is not None. Please use freq via the Tsfeatures class. ↓
cause Passing `freq` directly to `calculate_features` method in newer versions.
fix
Instantiate Tsfeatures with freq:
tf = Tsfeatures(freq=7) then call tf.calculate_features(df) without freq argument. error TypeError: 'NoneType' object is not callable ↓
cause Missing optional dependency (antropy) leads to internal function returning None when called.
fix
Install missing dependency:
pip install antropy. Alternatively, avoid entropy features by setting features=['all'] but this may still call entropy functions. Warnings
breaking Changed from function-based to class-based API in v0.1.0. Old code using `tsfeatures.calculate_features(df)` no longer works. Use `Tsfeatures().calculate_features(df)` instead. ↓
fix Upgrade to >=0.1.0 and use the Tsfeatures class.
gotcha Input DataFrame must have a DatetimeIndex; otherwise features relying on frequency detection (like seasonal features) may fail or produce NaNs. ↓
fix Ensure index is a pandas DatetimeIndex with a recognizable frequency (e.g., 'D', 'H'). If not needed, use `Tsfeatures(freq=1)` to treat as non-seasonal.
gotcha Some features require the `antropy` library; if not installed, those features are silently skipped. No error raised. ↓
fix Install antropy: `pip install antropy` to get entropy-based features.
deprecated The `freq` parameter in `calculate_features` is deprecated as of v0.4.0. Use `Tsfeatures(freq=...)` constructor instead. ↓
fix Pass frequency to Tsfeatures constructor: `tf = Tsfeatures(freq=24)`.
Imports
- Tsfeatures
from tsfeatures import Tsfeatures - calculate_features wrong
import tsfeatures; tsfeatures.calculate_features(df)correctfrom tsfeatures import Tsfeatures; tf = Tsfeatures(); result = tf.calculate_features(df)
Quickstart
import pandas as pd
from tsfeatures import Tsfeatures
# Sample time series data: one column with datetime index
dates = pd.date_range('2020-01-01', periods=50, freq='D')
df = pd.DataFrame({'value': [i + (i%10)*0.5 for i in range(50)]}, index=dates)
tf = Tsfeatures()
features = tf.calculate_features(df)
print(features)