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

Function pd_split

dask/dataframe/dask_expr/_expr.py:1786–1795  ·  view source on GitHub ↗
(df, p, random_state=None, shuffle=False)

Source from the content-addressed store, hash-verified

1784
1785
1786def pd_split(df, p, random_state=None, shuffle=False):
1787 p = list(p)
1788 if shuffle:
1789 if not isinstance(random_state, np.random.RandomState):
1790 random_state = np.random.RandomState(random_state)
1791 df = df.sample(frac=1.0, random_state=random_state)
1792 index = pseudorandom(len(df), p, random_state)
1793 if df.ndim == 1:
1794 df = df.to_frame()
1795 return df.assign(_split=index)
1796
1797
1798class Split(Elemwise):

Callers

nothing calls this directly

Calls 5

pseudorandomFunction · 0.90
sampleMethod · 0.80
assignMethod · 0.80
RandomStateMethod · 0.45
to_frameMethod · 0.45

Tested by

no test coverage detected