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

Function pd_split

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

Source from the content-addressed store, hash-verified

1780
1781
1782def pd_split(df, p, random_state=None, shuffle=False):
1783 p = list(p)
1784 if shuffle:
1785 if not isinstance(random_state, np.random.RandomState):
1786 random_state = np.random.RandomState(random_state)
1787 df = df.sample(frac=1.0, random_state=random_state)
1788 index = pseudorandom(len(df), p, random_state)
1789 if df.ndim == 1:
1790 df = df.to_frame()
1791 return df.assign(_split=index)
1792
1793
1794class 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