【问题标题】:adding a variable to an entity - featuretools向实体添加变量 - featuretools
【发布时间】:2019-02-28 17:35:16
【问题描述】:

我正在尝试向实体添加一个新变量。

我正在尝试添加如下变量:

es['Product'].add_variable("inventory", data=inventory_series)

但是我收到了这个错误:

TypeError: 'Series' objects are mutable, thus they cannot be hashed

如果我将类型参数指定为 int,

es['Product'].add_variable("inventory", data=inventory_series)

我得到一个不同的错误:

--> 558         new_v = type(new_id, entity=self)
    559         self.variables.append(new_v)
    560 

TypeError: 'entity' is an invalid keyword argument for this function

是否有另一种方法可以将新变量添加到实体?

谢谢,

【问题讨论】:

  • 一个问题 - 在创建实体时,有什么理由不能将此变量添加到原始数据框中?我之所以这么问,是因为计划在下一版本的 featuretools 中删除此方法,以鼓励用户在创建实体集之前进行数据准备。

标签: python featuretools


【解决方案1】:

您需要在add_variable 中指定数据类型。我猜你已经尝试过这种方式:

es['Product'].add_variable('inventory', data=inventory_series, type=int)

得到了这个错误:

TypeError: 'entity' 是该函数的无效关键字参数

但类型必须是featuretools.variable_types 中的一种。像这样:

es['Product'].add_variable(
    'inventory',
    data=inventory_series,
    type=ft.variable_types.Ordinal
)

【讨论】:

    猜你喜欢
    • 2021-12-05
    • 1970-01-01
    • 2012-05-18
    • 1970-01-01
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 2021-02-05
    相关资源
    最近更新 更多