【问题标题】:Can Pandas's `to_datetime` parse BCE dates?Pandas 的 `to_datetime` 可以解析 BCE 日期吗?
【发布时间】:2020-09-15 13:36:03
【问题描述】:

给定一个像公元前 8300 年这样的日期,我运行 pd.to_datetime("-8300", format="%y")

这会产生ValueError: time data '-8300' does not match format '%y' (match)

有没有办法在 Pandas 中处理“负”日期?

【问题讨论】:

    标签: pandas


    【解决方案1】:

    是的,

    我希望这个answer 有所帮助。

    Julian 日期的文档中有一个程序,您可以找到 here。关注unit & origin 参数

    【讨论】:

    • 你能举个例子吗? pd.to_datetime("1970", unit="D", origin="julian") 产生 ValueError: incompatible 'arg' type for given 'origin'='julian'。如果我将 1970 设为 int 而不是 str,我会得到 OutOfBoundsDatetime
    猜你喜欢
    • 2020-08-15
    • 2012-10-28
    • 1970-01-01
    • 2019-04-04
    • 2023-03-17
    • 2019-04-27
    • 1970-01-01
    • 2021-07-23
    相关资源
    最近更新 更多