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
  • 66,763
  • 15
  • 141
  • 151
ubuntu_noob
  • 2,145
  • 3
  • 20
  • 55

1 Answers1

1

Thanks @Zero

df['node1'].nunique()

This works for my answer

ubuntu_noob
  • 2,145
  • 3
  • 20
  • 55