0
data = { 
        'node1': [2,2,2,3,3,5,5],
        'node2': [8,16,22,5,25,10,77],
        'weight': [1,1,1,1,1,1,1], }
df = pd.DataFrame(data, columns = ['node1','node2','weight'])

print df["node1"].value_counts()

This gives the output as :

2 3
3 2
5 2

But I desire the answer 3 as that is the number of unique values of rows in column node1

Zero
  • 74,117
  • 18
  • 147
  • 154
ubuntu_noob
  • 2,305
  • 6
  • 23
  • 64

1 Answers1

1

Thanks @Zero

df['node1'].nunique()

This works for my answer

ubuntu_noob
  • 2,305
  • 6
  • 23
  • 64