calendar¶
- calendar(dt, /)[source]¶
Convert an array of datetime64 values to a calendar array of years, months, days, hours, minutes, and seconds. Adds a trailing axis of length 6.
- Parameters
dt (datetime array) – A datetime array with arbitrary shape. May be a
pandas.DatetimeIndex
array, anumpy.datetime64
array, or an object-type array of native pythondatetime.datetime
instances.- Returns
cal (uint32 array (…, 6)) – A calendar array matching the shape of the input array up to the rightmost axis. The rightmost axis is length 6; its indices contain the years, months, days, hours, minutes, and seconds of the input datetimes.
Examples
>>> import pandas as pd >>> import climopy as climo >>> idx = pd.date_range('2000-01-01', '2000-01-03', freq='450T') >>> climo.calendar(idx) array([[2000, 1, 1, 0, 0, 0], [2000, 1, 1, 7, 30, 0], [2000, 1, 1, 15, 0, 0], [2000, 1, 1, 22, 30, 0], [2000, 1, 2, 6, 0, 0], [2000, 1, 2, 13, 30, 0], [2000, 1, 2, 21, 0, 0]], dtype=uint32)