Python 3.x AttributeError:父变量'&书信电报;变量:用户id(数据类型=数字)>';不是实体:列车变量的索引:
我试图基于两个数据帧中相同的两列创建实体关系,但我得到了标题中所述的错误 在Internet上搜索该问题,但找不到任何内容Python 3.x AttributeError:父变量'&书信电报;变量:用户id(数据类型=数字)>';不是实体:列车变量的索引:,python-3.x,entity-relationship,featuretools,Python 3.x,Entity Relationship,Featuretools,我试图基于两个数据帧中相同的两列创建实体关系,但我得到了标题中所述的错误 在Internet上搜索该问题,但找不到任何内容 es = es.entity_from_dataframe(entity_id="train", dataframe=df_es_train, index="impression_id", ti
es = es.entity_from_dataframe(entity_id="train",
dataframe=df_es_train,
index="impression_id",
time_index="impression_time",
)
es = es.entity_from_dataframe(entity_id="viewlogs",
dataframe=df_es_view_logs,
index="index",
time_index="server_time",
)
es = es.entity_from_dataframe(entity_id="itemdata",
dataframe=df_es_item_data,
index="item_id",
)
new_relationship_1 = ft.Relationship(es["itemdata"]["item_id"],
es["viewlogs"]["item_id"])
es = es.add_relationship(new_relationship_1)
new_relationship = ft.Relationship(es["train"]["user_id"],
es["viewlogs"]["user_id"])
es = es.add_relationship(new_relationship)
实际结果是下面的错误,而这应该正确工作
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-43-62d742a93d26> in <module>
21 es = es.add_relationship(new_relationship_1)
22 new_relationship = ft.Relationship(es["train"]["user_id"],
---> 23 es["viewlogs"]["user_id"])
24 es = es.add_relationship(new_relationship)
D:\Anaconda3\envs\fastai\lib\site-packages\featuretools\entityset\relationship.py in __init__(self, parent_variable, child_variable)
25 if (parent_variable.entity.index is not None and
26 parent_variable.id != parent_variable.entity.index):
---> 27 raise AttributeError("Parent variable '%s' is not the index of entity %s" % (parent_variable, parent_variable.entity))
28
29 @classmethod
AttributeError: Parent variable '<Variable: user_id (dtype = numeric)>' is not the index of entity Entity: train
Variables:
impression_id (dtype: index)
impression_time (dtype: datetime_time_index)
user_id (dtype: numeric)
app_code (dtype: numeric)
os_version (dtype: numeric)
is_4G (dtype: numeric)
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在里面
21 es=es.添加关系(新关系1)
22新关系=英尺关系(es[“火车”][“用户id”],
--->23 es[“查看日志”][“用户id”])
24 es=es.添加关系(新关系)
D:\Anaconda3\envs\fastai\lib\site packages\featuretools\entityset\relationship.py in\uuuuuu init\uuuuu(self、parent\u变量、child\u变量)
25如果(parent_variable.entity.index)不是无,则
26 parent_variable.id!=parent_variable.entity.index):
--->27 raise AttributeError(“父变量“%s”不是实体%s”%的索引(父变量,父变量.entity))
28
29@classmethod
AttributeError:父变量“”不是实体:train的索引
变量:
印象标识(数据类型:索引)
印象时间(数据类型:日期时间索引)
用户id(数据类型:数字)
应用程序代码(数据类型:数字)
os_版本(数据类型:数字)
is_4G(数据类型:数字)
形状:
(行:237609,列:6)我遇到了同样的问题。我相信这是应该的,因为一个数据集包含100000行,而另一个只有30000行。因此,第一个数据集有70000行,其中没有ID(您定义的featuretools索引)来匹配第二个数据集 我的猜测是“连接”这两个数据集,将它们的大小减少到30000行。当然,当您有多个关系时,会导致删除大量信息,因为您需要减小所有数据集的大小 如果我找到其他方法,我会把它们贴在这里 备选方法1:我与这个问题有4种关系。我通过颠倒第一个和最后一个参数解决了3 由此
r_order_items_sellers = ft.Relationship(es['order_items']['seller_id'], es['sellers']['seller_id'])
对此
r_order_items_sellers = ft.Relationship(es['sellers']['seller_id'], es['order_items']['seller_id'])
我遇到了同样的问题。我相信这是应该的,因为一个数据集包含100000行,而另一个只有30000行。因此,第一个数据集有70000行,其中没有ID(您定义的featuretools索引)来匹配第二个数据集 我的猜测是“连接”这两个数据集,将它们的大小减少到30000行。当然,当您有多个关系时,会导致删除大量信息,因为您需要减小所有数据集的大小 如果我找到其他方法,我会把它们贴在这里 备选方法1:我与这个问题有4种关系。我通过颠倒第一个和最后一个参数解决了3 由此
r_order_items_sellers = ft.Relationship(es['order_items']['seller_id'], es['sellers']['seller_id'])
对此
r_order_items_sellers = ft.Relationship(es['sellers']['seller_id'], es['order_items']['seller_id'])
错误是说
user\u id
不是实体的主键。FT中的关系是一对多的,这就是为什么user\u id
必须是主键的原因错误是user\u id
不是实体的主键。FT中的关系是一对多的,这就是为什么user\u id
必须是主键的原因