Reputation: 906
my df called symbols looks like this:
local_symbol code globex expiry_date type strike
symbol
OZN20121221P00014900_FOP P OZN DEC 12 14900 CBT_21_F2013_S OZN 2012-12-21 P 149.0
OZN20121221C00012500_FOP C OZN DEC 12 12500 CBT_21_F2013_S OZN 2012-12-21 C 125.0
OZN20121221P00012450_FOP P OZN DEC 12 12450 CBT_21_F2013_S OZN 2012-12-21 P 124.5
OZN20121221C00013900_FOP C OZN DEC 12 13900 CBT_21_F2013_S OZN 2012-12-21 C 139.0
OZN20121221C00010700_FOP C OZN DEC 12 10700 CBT_21_F2013_S OZN 2012-12-21 C 107.0
using pandas 0.22.0 the following worked:
exp_date = dt.date(2012, 12, 21)
code = 'CBT_21_F2013_S'
type = 'P'
strike = 124.5
symbols.loc[(symbols.expiry_date == exp_date)
& (symbols.code == code)
& (symbols.type == type)
& (symbols.strike == strike)]
and returned OZN20121221P00012450_FOP as the expected value. In Pandas 0.23 i get an empty dataframe. Your help would be greatly appreciated.
Upvotes: 1
Views: 1905
Reputation: 863256
I believe need convert column expiry_date
to date
s and for compare floats use numpy.isclose
:
symbols.loc[(symbols.expiry_date.dt.date == exp_date)
& (symbols.code == code)
& (symbols.type == type)
& np.isclose((symbols.strike, strike)]
Upvotes: 1