featuretools.primitives.RollingSTD

class featuretools.primitives.RollingSTD(window_length=3, gap=0, min_periods=1)[source]

Calculates the standard deviation of entries over a given window.

Description:

Given a list of numbers and a corresponding list of datetimes, return a rolling standard deviation of the numeric values, starting at the row gap rows away from the current row and looking backward over the specified time window (by window_length and gap). Input datetimes should be monotonic.

Parameters
  • window_length (int) – The number of rows to be included in each frame. For data with a uniform sampling frequency, for example of one day, the window_length will correspond to a period of time, in this case, 7 days for a window_length of 7.

  • gap (int, optional) – The number of rows backward from the target instance before the window of usable data begins. Defaults to 0, which will include the target instance in the window.

  • min_periods (int, optional) – Minimum number of observations required for a window to have a value. Can only be as large as window_length. Defaults to 1.

Examples

>>> import pandas as pd
>>> rolling_std = RollingSTD(window_length=4)
>>> times = pd.date_range(start='2019-01-01', freq='1min', periods=5)
>>> rolling_std(times, [4, 3, 2, 1, 0]).tolist()
[nan, 0.7071067811865476, 1.0, 1.2909944487358056, 1.2909944487358056]

We can also control the gap before the rolling calculation.

>>> import pandas as pd
>>> rolling_std = RollingSTD(window_length=4, gap=1)
>>> times = pd.date_range(start='2019-01-01', freq='1min', periods=5)
>>> rolling_std(times, [4, 3, 2, 1, 0]).tolist()
[nan, nan, 0.7071067811865476, 1.0, 1.2909944487358056]

We can also control the minimum number of periods required for the rolling calculation.

>>> import pandas as pd
>>> rolling_std = RollingSTD(window_length=4, min_periods=4)
>>> times = pd.date_range(start='2019-01-01', freq='1min', periods=5)
>>> rolling_std(times, [4, 3, 2, 1, 0]).tolist()
[nan, nan, nan, 1.2909944487358056, 1.2909944487358056]
__init__(window_length=3, gap=0, min_periods=1)[source]

Methods

__init__([window_length, gap, min_periods])

generate_name(base_feature_names)

generate_names(base_feature_names)

get_args_string()

get_arguments()

get_description(input_column_descriptions[, ...])

get_filepath(filename)

get_function()

Attributes

base_of

base_of_exclude

commutative

compatibility

Additional compatible libraries

default_value

Default value this feature returns if no data found.

description_template

input_types

woodwork.ColumnSchema types of inputs

max_stack_depth

name

Name of the primitive

number_output_features

Number of columns in feature matrix associated with this feature

return_type

ColumnSchema type of return

uses_calc_time

uses_full_dataframe