Lee Hongwei
Lee Hongwei

Reputation: 47

Condition pandas data Frame

columuns in my data are [Instrument,Account Number,Trade PnL]

How can i find the number of unique account number given with condition that Instrument =='AAPL'

    df[['Account Number'](df['Instrument'] == 'AAPL'].nunique()

Upvotes: 0

Views: 32

Answers (1)

Pygirl
Pygirl

Reputation: 13349

This should be:

df['Account Number'][df['Instrument'] == 'AAPL'].nunique()

Upvotes: 1

Related Questions