<!--
{
  "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/grouped(by:timeUnit:)-78cy",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "TabularData"
    ],
    "preciseIdentifier" : "s:11TabularData0B13FrameProtocolPAAE7grouped2by8timeUnitAA11RowGroupingVySiGAA8ColumnIDVy10Foundation4DateVG_AL8CalendarV9ComponentOtF"
  },
  "title" : "grouped(by:timeUnit:)"
}
-->

# grouped(by:timeUnit:)

Creates a grouping of rows that the method selects
by choosing unique units of time in a date column you select by column identifier.

```
func grouped(by columnID: ColumnID<Date>, timeUnit: Calendar.Component) -> RowGrouping<Int>
```

## Parameters

`columnID`

A column identifier.

`timeUnit`

A component of a calendar date.

## Return Value

A collection of groups.

## Discussion

After the method aggregates the groups, it creates a column with the same name as the original column
plus the `timeUnit` name.

---

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)