首页 > 解决方案 > 'float' 对象没有属性 'utcoffset'", '发生在索引 30852'

问题描述

我试图使用以下代码本地化数据集的时区:

df['Date and Time'] = df['Date and Time'].astype('datetime64')
df['Date and Time'] = df.apply(lambda r : r['Date and Time (RW)'].tz_localize(r['Zone']), 1)

但是,我不断收到错误消息,上面写着:

"'float' 对象没有属性 'utcoffset'", '发生在索引 30852"

当我试图查看导致错误的数据时:

df[(df.index==30852)] # actually it shows that there is no data. 

我尝试通过运行以下代码删除该索引处的数据:

df.drop(df.index[30852], inplace=True)

但它没有用,因为没有数据。

什么可能导致此错误?

标签: python-3.xpandastimezone-offset

解决方案


推荐阅读