@@ -1079,24 +1079,13 @@ E.g., pickle/unpickle an array stored on disk::
1079
1079
Datetimes and timedeltas
1080
1080
------------------------
1081
1081
1082
- Please note that NumPy's ``datetime64 `` and ``timedelta64 `` dtypes are **not ** currently
1083
- supported for Zarr arrays. If you would like to store datetime or timedelta data, you
1084
- can store the data in an array with an integer dtype, e.g.::
1082
+ NumPy's ``datetime64 `` ('M') and ``timedelta64 `` ('m') dtypes are supported for Zarr
1083
+ arrays, as long as the units are specified. E.g.::
1085
1084
1086
- >>> a = np.array(['2007-07-13', '2006-01-13', '2010-08-13'], dtype='datetime64[D]')
1087
- >>> z = zarr.array(a.view('i8'))
1085
+ >>> z = zarr.array(['2007-07-13', '2006-01-13', '2010-08-13'], dtype='M[D]')
1088
1086
>>> z
1089
- <zarr.core.Array (3,) int64 >
1087
+ <zarr.core.Array (3,) datetime64[D] >
1090
1088
>>> z[:]
1091
- array([13707, 13161, 14834])
1092
- >>> z[:].view(a.dtype)
1093
- array(['2007-07-13', '2006-01-13', '2010-08-13'], dtype='datetime64[D]')
1094
-
1095
- If you would like a convenient way to retrieve the data from this array viewed as the
1096
- original datetime64 dtype, try the :func: `zarr.core.Array.astype ` method, e.g.::
1097
-
1098
- >>> zv = z.astype(a.dtype)
1099
- >>> zv[:]
1100
1089
array(['2007-07-13', '2006-01-13', '2010-08-13'], dtype='datetime64[D]')
1101
1090
1102
1091
.. _tutorial_tips :
0 commit comments