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

Function _sort_mixed

dask/dataframe/dask_expr/_expr.py:3893–3908  ·  view source on GitHub ↗

order ints before strings before nulls in 1d arrays

(values)

Source from the content-addressed store, hash-verified

3891
3892
3893def _sort_mixed(values):
3894 """order ints before strings before nulls in 1d arrays"""
3895 str_pos = np.array([isinstance(x, str) for x in values], dtype=bool)
3896 tuple_pos = np.array([isinstance(x, tuple) for x in values], dtype=bool)
3897 null_pos = np.array([pd.isna(x) for x in values], dtype=bool)
3898 num_pos = ~str_pos & ~null_pos & ~tuple_pos
3899 str_argsort = np.argsort(values[str_pos])
3900 tuple_argsort = np.argsort(values[tuple_pos])
3901 num_argsort = np.argsort(values[num_pos])
3902 # convert boolean arrays to positional indices, then order by underlying values
3903 str_locs = str_pos.nonzero()[0].take(str_argsort)
3904 tuple_locs = tuple_pos.nonzero()[0].take(tuple_argsort)
3905 num_locs = num_pos.nonzero()[0].take(num_argsort)
3906 null_locs = null_pos.nonzero()[0]
3907 locs = np.concatenate([num_locs, str_locs, tuple_locs, null_locs])
3908 return values.take(locs)
3909
3910
3911def 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