Я хотел добавлять 5 дней каждый день в свой оригинальный DataFrame
Сначала я импортировал необходимые компоненты
import pandas as pd
import datetime as dt
pd.core.common.is_list_like = pd.api.types.is_list_like
from pandas_datareader import data
import pandas_datareader.data as web
from datetime import datetime
Затем я создал свой DataFrame
company = "MSFT"
start = datetime(2015, 2, 9)
end = dt.datetime.now()
stocks = web.DataReader(company, "iex",start,end)
Теперь я хотел добавить 5 дней до начала DataFrame.Поэтому я использовал DateOffset
stocks.index
stocks.index + pd.DateOffset(days = 5)
И теперь он показывает эту ошибку
TypeError Traceback (последний последний вызов) в () ----> 1 stocks.index +pd.DateOffset (days = 5)
/ anaconda2 / lib / python2.7 / site-packages / pandas / core / indexes / base.pyc в add (self, other) 26842685 def add (self, other): -> 2686 Индекс возврата (np.array (self) + other) 2687 2688 def radd (self, other):
pandas / _libs / tslibs / offsets.pyx в pandas._libs.tslibs.offsets.BaseOffset. radd ()
/ anaconda2 / lib / python2.7 / site-packages /pandas / tseries / offsets.pyc в add (self, other) 346 return other + self 347 try: -> 348 return self.apply (other) 349 кроме ApplyTypeError: 350 return NotImplemented
/ anaconda2 / lib / python2.7 / site-packages / pandas / tseries / offsets.pyc в оболочке (self, other) 75 other = other.tz_localize (None) 76 ---> 77 result = func (self,другое) 78 79 если self._adjust_dst:
/ anaconda2 / lib /python2.7 / site-packages / pandas / tseries / offsets.pyc в apply (self, other) 212, если self.n> 0: 213 для i в диапазоне (self.n): -> 214 other = other + self._offset 215 остальное: 216 для i в диапазоне (-self.n):
Ошибка типа: приведение к Unicode: требуется строка или буфер, найдена относительная дельта