【发布时间】:2020-05-03 07:59:15
【问题描述】:
我正在使用 start_date 和 end_date 数据帧,但我的循环遇到了问题,返回以下错误:AttributeError: 'Series' object has no attribute 'days'
我尝试添加 .iterrows()、.dt.days、pandas.Series.iteritems 均未成功
# Function to get a list of all dates that are to be downloaded
def get_dates():
df1 = pd.read_csv(r"C:\Users\14385\PycharmProjects\execvet_actrivist_db\short_seller_database.csv")
raw_start_date = df1['Publication Date']
start_date= pd.to_datetime(raw_start_date)
ticker = df1['Ticker']
end_date = start_date + timedelta(days=365) # One year trailing calendar days acc. to IEX docu
**dates = [start_date + timedelta(days=i) for i in range((end_date - start_date).days)] ##.dt.days Not working either**
我还尝试将系列转换为数据框( dates = [start_date + timedelta(days=i) for i in range((end_date.to_frame() - start_date.to_frame))])但失败了
感谢您的帮助!
【问题讨论】: