【问题标题】:Changing a row of datetime values in a csv to Julian Dates将 csv 中的一行日期时间值更改为 Julian Dates
【发布时间】:2018-10-08 18:40:48
【问题描述】:

以下是我正在使用的 CSV:

我想编辑此行中的所有日期时间值,以便显示儒略日期。这可能吗?

我想我需要将行拆分和 csv 写入结合起来,但我不确定从哪里开始。

【问题讨论】:

    标签: python pandas csv numpy


    【解决方案1】:

    这将起作用:

    import datetime
    import math
    
    def get_julian_datetime(date):
    
    # Perform the calculation
    julian_datetime = 367 * date.year - int((7 * (date.year + int((date.month + 9) / 12.0))) / 4.0) + int(
        (275 * date.month) / 9.0) + date.day + 1721013.5 + (
                          date.hour + date.minute / 60.0 + date.second / math.pow(60,
                                                                                  2)) / 24.0 - 0.5 * math.copysign(
        1, 100 * date.year + date.month - 190002.5) + 0.5
    
    return julian_datetime
    

    例子:

    example_datetime = datetime.datetime(2015, 9, 26, 4, 30, 0)
    print get_julian_datetime(example_datetime)
    

    【讨论】:

    • 是的!谢谢!
    猜你喜欢
    • 1970-01-01
    • 2019-07-23
    • 1970-01-01
    • 2013-12-28
    • 2019-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多