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

Function _sort_mixed

dask/dataframe/dask_expr/_expr.py:3897–3912  ·  view source on GitHub ↗

order ints before strings before nulls in 1d arrays

(values)

Source from the content-addressed store, hash-verified

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