Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Featuretools create index from multiple columns

Tags:

featuretools

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'

like image 262
lcampos Avatar asked May 08 '26 08:05

lcampos


1 Answers

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.

like image 60
Max Kanter Avatar answered May 10 '26 20:05

Max Kanter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!