0

I have a dataframe with a single column and 1200 rows. There are a total of 3 possible values in each row - 'No difference', 'Opposite sex' or 'Same sex'. The column header is 'Friends' I'm trying to sum up the total number of results for each value using

df2 = df1.groupby(['Friends']).sum()

but I end up with an empty dataframe as the result (df2)

Danila Ganchar
  • 10,266
  • 13
  • 49
  • 75
  • 2
    Welcome so stack overflow! If you have a single column, then you have a series, not a dataframe. Perhaps the `series.value_counts()` method might help here – G. Anderson Jan 08 '20 at 20:48
  • Does this answer your question? [count the frequency that a value occurs in a dataframe column](https://stackoverflow.com/questions/22391433/count-the-frequency-that-a-value-occurs-in-a-dataframe-column) – AMC Jan 08 '20 at 21:44

1 Answers1

1

try

df2 = df1['Friends'].value_counts()
hchw
  • 1,388
  • 8
  • 14