featuretools.primitives.SameAsPrevious#

class featuretools.primitives.SameAsPrevious(fill_method='pad', limit=None)[source]#

确定列表中的一个值是否等于前一个值.

Description:

将列表中的一个值与前一个值进行比较,如果该值等于前一个值则返回True,否则返回False. 由于第一个元素没有前一个元素进行比较,因此输出中的第一个元素始终为False.

输入中的任何NaN值将根据fill_method参数指定的前向填充或后向填充方法进行填充. 可以通过limit参数限制连续NaN值的填充数量.填充后剩余的任何NaN值将导致涉及该NaN值的任何比较返回False.

Parameters:
  • fill_method (str) – 用于填充序列中空隙的方法.有效选项为`backfill`、bfillpadffill.

  • ffill (pad /) – 用最后一个有效观测值填充空隙.

  • bfill (backfill /) – 用下一个有效观测值填充空隙.

  • 默认值为`pad`.

  • limit (int) – 可以填充的连续NaN值的最大数量.默认值为None.

Examples

>>> same_as_previous = SameAsPrevious()
>>> same_as_previous([1, 2, 2, 4]).tolist()
[False, False, True, False]

NaN值的填充方法可以指定

>>> same_as_previous_fillna = SameAsPrevious(fill_method="bfill")
>>> same_as_previous_fillna([1, None, 2, 4]).tolist()
[False, False, True, False]

可以限制填充的NaN值数量

>>> same_as_previous_limitfill = SameAsPrevious(limit=2)
>>> same_as_previous_limitfill([1, None, None, None, 2, 3]).tolist()
[False, True, True, False, False, False]
__init__(fill_method='pad', limit=None)[source]#

Methods

__init__([fill_method, limit])

flatten_nested_input_types(input_types)

将嵌套的列模式输入展平成一个列表.

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

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

stack_on

stack_on_exclude

stack_on_self

uses_calc_time

uses_full_dataframe