问题
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