首页 > 解决方案 > AttributeError:'Timestamp'对象在python中没有属性'split'

问题描述

#Create the independent data set
for day in df_days:
    days.append([int(day.split('-')[4])])
#Create the dependent data set (adj close prices)
for adj_close_price in df_adj_close:
    adj_close_prices.append( float(adj_close_price))

我收到错误消息 #"AttributeError: 'Timestamp' object has no attribute 'split'"

有人可以帮忙吗?

标签: pythonsplitattributestimestampattributeerror

解决方案


我相信您需要一个字符串对象来执行滑动操作。我相信你正在使用时间戳(“日期时间”类型)对象。如果您使用“datetime”,请对对象使用字符串格式或直接在时间戳对象上使用“day = datetimeobj.strftime("%d")”。如果您使用的是时间戳,请先将其转换为“datetime”、“datetimeobj=datetime.fromtimestamp(timestamp)”


推荐阅读