Unexpected behaviour with Pandas on databricks

Viewed 57

I am using Pandas in data bricks, whenever I am trying to use the sum() or mean() function, it's not giving me the desired result, while all the other functions like value_count(),sort_value(), and other functions are working perfectly fine

Here is the code

df_fpl.groupby("team")["goals_scored"].sum()

Here is the output

ARS    0000000000000000000000000000000000000000000000...

AVL    0000000000000000000000000000000000000000000000...

BHA    0000000000000000000000000000000000000000000000...

BUR    0000000000000000000000000000000000000000000000...

CHE    0000000000000000000000000000000000000000000000...

CRY    0000000000000000000100000000010000000000000000...

EVE    0000000000000000000000000000000000000000000000...

FUL    0000000010000000000000000000000000000000000000...

LEE    0000000000000000000000000000000000000000000000...

LEI    0000000000000000000000000000000000000000000000...

LIV    0000000000000000000000000000000000000000000000...

MCI    0000000000000000000000000000000000000000000000...

MUN    0000000000000000000000000000000000000000000000...

NEW    0000000000000000000000100000010110111100000000...

SHU    0000000000000000000000000000000000000000001000...

SOU    0000000001000100000000000000000000001000000000...

TOT    0000000000000000000000000000000000000000000000...

WBA    0000000000000000000000000000000000000000000000...

WHU    0000000000000000000002001010112100000000000000...

WOL    0000000000000000000000000000000000000000000000...
Name: goals_scored, dtype: object

what I really need is

ARS 15

AVL 20

BUR 10

and so on.

1 Answers

This problem is due to the column in question being a string. If you convert it to an int, that should solve it.

Related