MCPcopy Create free account
hub / github.com/dask/dask / _sort_mixed

Function _sort_mixed

dask/dataframe/dask_expr/_expr.py:3937–3952  ·  view source on GitHub ↗

order ints before strings before nulls in 1d arrays

(values)

Source from the content-addressed store, hash-verified

3935
3936
3937def _sort_mixed(values):
3938 """order ints before strings before nulls in 1d arrays"""
3939 str_pos = np.array([isinstance(x, str) for x in values], dtype=bool)
3940 tuple_pos = np.array([isinstance(x, tuple) for x in values], dtype=bool)
3941 null_pos = np.array([pd.isna(x) for x in values], dtype=bool)
3942 num_pos = ~str_pos & ~null_pos & ~tuple_pos
3943 str_argsort = np.argsort(values[str_pos])
3944 tuple_argsort = np.argsort(values[tuple_pos])
3945 num_argsort = np.argsort(values[num_pos])
3946 # convert boolean arrays to positional indices, then order by underlying values
3947 str_locs = str_pos.nonzero()[0].take(str_argsort)
3948 tuple_locs = tuple_pos.nonzero()[0].take(tuple_argsort)
3949 num_locs = num_pos.nonzero()[0].take(num_argsort)
3950 null_locs = null_pos.nonzero()[0]
3951 locs = np.concatenate([num_locs, str_locs, tuple_locs, null_locs])
3952 return values.take(locs)
3953
3954
3955def plain_column_projection(expr, parent, dependents, additional_columns=None):

Callers 1

Calls 3

takeMethod · 0.80
nonzeroMethod · 0.80
isnaMethod · 0.45

Tested by

no test coverage detected