python - TypeError: 'DatetimeIndex' object is not callable -


i have following data:

                high  date  2017-07-17    150.90  2017-07-18    150.13  2017-07-19    151.42  2017-07-20    151.74  2017-07-21    150.44  2017-07-24    152.44 

i trying index putting in value inside highs.index(values) unable index.

import datetime dt datetime import timedelta td import pandas pd import pandas_datareader.data web import numpy np  start = dt.datetime(2017, 7, 15) df = web.datareader('aapl', 'google', start) highs = df['high'] print('index = ',highs.index(150.44)) 

when use print('index = ',highs.index(150.44)) type error:

print('index = ',highs.index(150.44))

typeerror: 'datetimeindex' object not callable

is anyway datetime index using particular value dataframe?

it seems want index of column high 150.44. can this, boolean indexing:

in [711]: highs[df['high'] == 150.44].index out[711]: datetimeindex(['2017-07-21'], dtype='datetime64[ns]', name='date', freq=none) 

or, more simply:

in [748]: highs[df['high'] == 150.44].index.tolist()[0] out[748]: timestamp('2017-07-21 00:00:00') 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -