home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1081869682

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/6412#issuecomment-1081869682 https://api.github.com/repos/pydata/xarray/issues/6412 1081869682 IC_kwDOAMm_X85AfAVy 6628425 2022-03-29T13:25:46Z 2022-03-29T13:25:46Z MEMBER

I agree this should be better documented.

Here when I want to retrieve the year of datetime, instead of casting back to an array of object & using datetime.year, it's handy to use built-in numpy datetime64 conversion.

The recommended way to extract datetime components, like the year, is to use the DatetimeAccessor. For example if you have a DataArray of datetime-like values (whether they are of type np.datetime64[ns] or cftime.datetime) you can do something like this:

da.dt.year

and it will return a DataArray containing the year of each datetime (for more information see the "Datetime components" section of the documentation).

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 1,
    "rocket": 0,
    "eyes": 0
}
  1180565228
Powered by Datasette · Queries took 1.154ms · About: xarray-datasette