Reputation: 1978
I have run the following code
from pandas_datareader.data import Options
aapl = Options('aapl', 'yahoo')
data = aapl.get_all_data()
data.head()
let's say under 'Vol' there is one cell with value '13', how do i access that value in this dataframe? at first, i have tried data['Vol'] to get 'Vol' column but it failed
df=data.loc[(slice(None), slice(None), 'put'),'Vol':'Vol']
df
it seems i cannot get only 'Vol' column for some reason
Upvotes: 1
Views: 1857
Reputation: 862691
I think you need boolean indexing
with loc
- it return all values with 13
in column Vol
:
mask = data['Vol'] == 13
vals = data.loc[mask, 'Vol']
For first 13
select by position by iloc
or iat
:
first = vals.iloc[0]
first = vals.iat[0]
Upvotes: 1