Setting freq of pandas DatetimeIndex after DataFrame creation

后端 未结 3 520
猫巷女王i
猫巷女王i 2021-02-12 12:03

Im using pandas datareader to get stock data.

import pandas as pd
import pandas_datareader.data as web
ABB = web.DataReader(name=\'ABB.ST\', 
                           


        
3条回答
  •  醉梦人生
    2021-02-12 12:38

    Try:

    ABB = ABB.asfreq('d')
    

    This should change the frequency to daily with NaN for days without data.

    Also, you should rewrite your for-loop as follows:

    for index, row in ABB.iterrows():
        print(ABB.loc[[index + pd.Timedelta(days = 1)]])
    

    Thanks!

提交回复
热议问题