熊猫:从datetime64 [ns,UTC]中删除时区

时间:2019-06-22 14:51:10

标签: python pandas facebook-prophet

print(df.head)产生

    ds                                  y
0   2019-03-01 10:57:32.381378+00:00    18760
1   2019-03-01 10:58:30.933070+00:00    28140
2   2019-03-01 10:58:45.425421+00:00    35520
3   2019-03-01 10:59:11.588687+00:00    50280
4   2019-03-01 10:59:19.064323+00:00    72420

在尝试使用Facebook Prophet时,出现以下错误:ValueError: Column ds has timezone specified, which is not supported. Remove timezone.现在尝试从ds列中删除时区。您是否知道如何实现?

df = pd.read_csv(
    'wob-2019-ticket-sales.csv',
    usecols=['created', 'total_gross'],
    parse_dates=['created'],
    # date_parser=lambda x: pd.to_datetime(x.rpartition('-')[0])
)

df['y'] = df['total_gross'].cumsum()
df = df.rename(columns={'created': 'ds'})
df = df.drop(columns='total_gross')

df.head()

0 个答案:

没有答案