0

Using Python and Pandas: For a given data set, how do you find the number of a specific attribute? For example I have 16 columns of data with over 600 rows. I want to find how many of attribute "g" is in column A5. I have attached the code I found, but it does not give the correct value or use a specific column.

df = df['g'].value_counts().reset_index()
df.rows = ['g', 'count']
print(df)
mrw
  • 23
  • 3

1 Answers1

0

Subset value_counts().

df['g'].value_counts()['a']
Evan
  • 2,121
  • 14
  • 27