<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TabularData",
  "identifier" : "/documentation/TabularData/DataFrameProtocol/randomSplit(by:using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "TabularData"
    ],
    "preciseIdentifier" : "s:11TabularData0B13FrameProtocolPAAE11randomSplit2by5usingAA0bC0V5SliceV_AJtSd_qd__ztSGRd__lF"
  },
  "title" : "randomSplit(by:using:)"
}
-->

# randomSplit(by:using:)

Generates two data frame slices by randomly splitting the rows of the data table type
with a random-number generator.

```
func randomSplit<G>(by proportion: Double, using generator: inout G) -> (DataFrame.Slice, DataFrame.Slice) where G : RandomNumberGenerator
```

## Parameters

`proportion`

A proportion in the range `[0.0, 1.0]`.

`generator`

A random-number generator.

## Return Value

A tuple of two data frame slices.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)