0

based also on this post and this post, I try to count the frequency in a column. When I run it on a int64 column with:

df['value'].value_counts()

I get the desired outcome:

10000.00   2
50         1
....

Where when I run it on the object column:

df['text'].value_counts()

I get the error:

AttributeError: 'DataFrame' object has no attribute 'value_counts'

On top, if I run:

df.groupby('text').count()

I get the error:

ValueError: Grouper for 'WHRG GEGENWERT' not 1-dimensional

What could be the problem?

PV8
  • 5,799
  • 7
  • 43
  • 87

1 Answers1

1

Problem is duplicated columns names, here text, so after selecting get all dupe columns, so is returned DataFrame instead Series and raised errors.

Check it by:

print (df['text'])

If same values in each columns you can remove duplicates:

df = df.loc[:, ~df.columns.duplicated()]
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252