为什么tibble在读取羽毛文件后显示本地时间

问题描述

我有一个带有时间戳的熊猫数据框,像这样:

df = pd.DataFrame({'a': [pd.Timestamp('2020-01-01 00:00:00')]})

我使用df.to_feather('a.feather')将其写入一个羽毛文件,并使用df <- arrow::read_feather('a.feather')将其读回R。

当我显示它时,我看到

A tibble: 1 × 1 a
<dttm>
2020-01-01 01:00:00

01:00:00来自哪里?我该如何摆脱呢?

解决方法

好的,看来R或箭头正在注意某种全局时区变量。因此,可以通过添加

来修复上述行为
Sys.setenv(TZ='GMT')

在开始的时候。

受此启发:https://arrow.apache.org/docs/python/timestamps.html