为什么橄榄酸无法根据同一时区的Olson名称来解析一些日期?

发布于 2025-02-05 01:23:22 字数 1178 浏览 1 评论 0原文

我正在使用加那利群岛的一些数据。这个西班牙地区的时区正式湿/西。但是这个时区也与英国的时区相吻合-GMT/BST。两者都会改变同一天和同一天。

我尝试使用lubritation库将一些字符(日月)转换为日期,我感到惊讶的是,根据我使用的时区,函数dmy()可以无法解析。

当我尝试使用dmy() tz =“ atlantic/canary”> wet/west中的时区直接使用时区直接解析所有日期列。解析。这个:

example = c("06/04/1980", "06/04/1980", "06/04/1980", "06/04/1980", "06/04/1980", 
"23/10/2008", "27/03/2017", "24/02/2011", "06/04/1980")

但是,与以前不同,它独自一人尝试了3/9。

> dmy(example, tz = "Atlantic/Canary")
[1] NA                NA                NA                NA                NA                "2008-10-23 WEST"
[7] "2017-03-27 WEST" "2011-02-24 WET"  NA               
Warning message:
 6 failed to parse. 

更令人惊讶的是,如果我将时区设置为英国人,它可以很好地工作。另外,英国人一次可以立即适合所有专栏:

> dmy(example, tz = "Europe/London")
[1] "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "2008-10-23 BST" "2017-03-27 BST"
[8] "2011-02-24 GMT" "1980-04-06 BST"

我不明白为什么三个案例有所不同。我最初的DF是1000万行。但是,即使有9个日期的列表,我也不知道为什么使用一个TZ或另一个TZ dmy()函数输出有所不同。如果我使用数小时,也许会发生一些变化,但事实并非如此。任何答案都将不胜感激。

I'm working with some data from the Canary Islands. The timezone in this Spanish region is officially WET/WEST. But this timezone also coincides with the British one for example - GMT/BST. Both change same hour and same day.

I tried to convert some characters (day-month-year) to dates using lubridate library and I am surprised that depending on the timezone I use, the function dmy() can fail to parse or not.

When I tried to parse directly all the date column using the timezone in dmy() tz = "Atlantic/Canary" - which is WET/WEST - it returns 9 failings to parse. This ones:

example = c("06/04/1980", "06/04/1980", "06/04/1980", "06/04/1980", "06/04/1980", 
"23/10/2008", "27/03/2017", "24/02/2011", "06/04/1980")

However, trying them alone, it successfully converts 3 / 9, unlike before.

> dmy(example, tz = "Atlantic/Canary")
[1] NA                NA                NA                NA                NA                "2008-10-23 WEST"
[7] "2017-03-27 WEST" "2011-02-24 WET"  NA               
Warning message:
 6 failed to parse. 

And more surprisingly, If I set the timezone to British, it works perfectly. Also, the British one works perfectly for all the column at once:

> dmy(example, tz = "Europe/London")
[1] "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "2008-10-23 BST" "2017-03-27 BST"
[8] "2011-02-24 GMT" "1980-04-06 BST"

I don't understand why the 3 cases are different. My original df is 10 million rows. However, even with the list of 9 dates, I don't know why the dmy() function output differs using one tz or another. If I were using hours, maybe it would be for some change, but that is not the case. Any answer will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文