1

hello I have the following dataset: enter image description here I want to count the frequency of each value occuring across the entire dataset. I am aware of the value_count() which is works only on columns but not for the entire dataset. I used the following code:

df.value_counts()

But it results in an error:

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

Please could you help me count the frequency of values across the whole dataset?

tulock
  • 33
  • 4
  • **Please provide a [mcve], as well as the entire error message.** Also, please do not share information as images unless absolutely necessary. See: https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors, https://idownvotedbecau.se/imageofcode, https://idownvotedbecau.se/imageofanexception/. – AMC May 03 '20 at 01:28

1 Answers1

7

You can use the stack function to stack all values in one column, and then use value_counts:

df.stack().value_counts()
Daniel Geffen
  • 1,777
  • 1
  • 11
  • 16