【问题标题】:Day of month in xarrayxarray 中的月份日期
【发布时间】:2021-02-01 16:08:38
【问题描述】:

我有数据集数据,但发现异常,因此结果是包含坐标(经度、纬度)和时间以及时间为年份的数据数组。

到目前为止,如何将时间更改为 6 月 1 日、6 月 2 日...?

screenshot of xarray.DataArray

【问题讨论】:

    标签: python datetime dataset python-xarray dayofmonth


    【解决方案1】:

    我认为你可以这样做

    pandas.to_datetime(x['time'],origin=datetime.datetime(2020,1,1),unit="D")

    (假设 int 是今年的天数和 1 月 1 日 == 0)

    【讨论】:

    • 谢谢你,但我不需要年份,只需要我需要的月份和日期
    • dates = pandas.to_datetime(x['time'],origin=datetime.datetime(2020,1,1),unit="D");dates.year;dates.month 我猜?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    相关资源
    最近更新 更多