What is wrong with this code?

Hey,

I’m new to coding and I don’t understand what’s wrong or how to fix it. Thanks guys!

Inialise the categories_df_all dataframe

categories_df_all = pd.DataFrame()

Loop through the index_list

for i in range(0, len(index_list)-1):
transaction_description = unique_transactions[index_list[i]:index_list[i+1]]
transaction_description = ’ , '.join(transaction_description)

categories_df = categorize_transactions(transaction_description, llm)
categories_df_all = pd.concat([categories_df_all, categories_df], ignore_index=True)

This is the error code:
TypeError Traceback (most recent call last)
Cell In[104], line 7
5 for i in range(0, len(index_list)-1):
6 transaction_description = unique_transactions[index_list[i]:index_list[i+1]]
----> 7 transaction_description = ‘,’.join(transaction_description)
9 categories_df = categorize_transactions(transaction_description, llm)
10 categories_df_all = pd.concat([categories_df_all, categories_df], ignore_index=True)

TypeError: sequence item 22: expected str instance, float found

1 Like

Try adding str(). Explicit casting.

That seems to have worked thanks!

1 Like