How can i get the symbols of retdf
import pandas as pd
returns = [0.0322, 0.3211, 0.0032, 0.00349]
symbols = ['A', 'B', 'C', 'D']
retdf = pd.DataFrame(returns, index=symbols, columns=['ret'])
retdf = retdf.ret.nlargest(3).values > 0.03
print(retdf)
The above code outputs
array([ True, True, False])
You need to use boolean indexing after your condition is met.
tmp = retdf.ret.nlargest(3)
(tmp.loc[tmp > 0.03]).index
> Index(['B', 'A'], dtype='object')