Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: Cannot index with multidimensional key

Tags:

python

pandas

I am trying to code a simple recommender system using only pandas and I am having trouble with the filtering part.I want to select all the rows where the RatingCounts column is greater than a value I choose.This returns me a dataframe with one column filled with the correct booleans but i cannot index my data with this selection it gives me a value error as mentioned in the title.Here is the screenshot

enter image description here

like image 543
Furkan Kılıçaslan Avatar asked Feb 11 '18 17:02

Furkan Kılıçaslan


1 Answers

selection appears to be a 2D DataFrame with 1 column, RatingCounts. The error occurs when you pass a 2D indexer to DataFrame.loc. You can avoid the error by passing a 1D boolean indexer to DataFrame.loc:

final_data.loc[selection['RatingCounts']]
like image 130
unutbu Avatar answered Nov 20 '22 19:11

unutbu