Featuretools create index from multiple columns

杀马特。学长 韩版系。学妹 提交于 2019-12-11 12:23:48

问题


I am trying to create an entity from a dataframe using the entity_from_dataframe function in featuretools. Is there a way to define the index if it comprises of more than one column. I'm unsure if I need a list, tuple or some other data structure. This is the code:

es=es.entity_from_dataframe(entity_id="credit",
                       dataframe=credit_df,
                       index=["ID1","ID2"]
                       )

It generates the following error regarding hashability

TypeError: unhashable type: 'list'


回答1:


You can only have a single variable be your index. In your case, you should create a new column in your dataframe that is the concatenation of the two columns you want to use

df["index"] = df["ID1"].astype(str) + "_" + df["ID2"].astype(str)

Then, you can use index as the index when creating the entity.



来源:https://stackoverflow.com/questions/51201612/featuretools-create-index-from-multiple-columns

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!