0
I want to show the percentage of various genres in my code with the date set and it is giving a following error:
Valueerror: Lengths must match to compare
The part that has the error in my code is like this, help me find the error
base = pd.read_csv ('gamestest.csv')
#base.Platform (a tabela excel possui uma coluna Platform)
porcen = base.DataFrame(base.Genre.unique())
totalPorcPlat = len(base)
for porc in porcen:
contagemPorcen = base[base.Genre]==porcen].shape(0)
print ('{}: {:0.2f}%'.format(porcen, contagemPorcen * 100/ totalPorcPlat))
I think the confusion is in
Platform
andPlatforms
. If it’s notfor Platforms in Platform:
, the last two lines should usePlatforms
plural, and notPlatform
. Check the indentation too, I think the code was copied wrong in the question.– AlexCiuffa
But in my algorithm there is a table called Platform
– user143390
base[base['Platform']==Platforms].shape[0]
and.format(Platforms, ...
. I meant the variable, not the column.– AlexCiuffa
It didn’t work, still returns the same error.
– user143390
Hey @Alexciuffa I had to change some parts of my code for better understanding, the change I made is the percentage of video game genre.
– user143390