MCPcopy
hub / github.com/pydata/xarray / factorize

Method factorize

xarray/tests/test_groupby.py:2881–2886  ·  view source on GitHub ↗
(self, group)

Source from the content-addressed store, hash-verified

2879 """
2880
2881 def factorize(self, group) -> EncodedGroups:
2882 assert np.issubdtype(group.dtype, np.datetime64)
2883 year = group.dt.year.data
2884 codes_, uniques = pd.factorize(year)
2885 codes = group.copy(data=codes_).rename("year")
2886 return EncodedGroups(codes=codes, full_index=pd.Index(uniques))
2887
2888 def reset(self):
2889 return type(self)()

Callers 2

test_lazy_groupingFunction · 0.45
test_lazy_int_bins_errorFunction · 0.45

Calls 3

EncodedGroupsClass · 0.90
renameMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected