DataStore Class Reference

# Multiple aggregations per column
grouped.agg({'amount': ['sum', 'mean', 'count']})

# Named aggregations
grouped.agg(
    total=('amount', 'sum'),
    average=('amount', 'mean'),
    count=('id', 'count')
)
```

---

## LazySeries[​](#lazyseries "Direct link to LazySeries")

Represents a lazy Series (single column).

### Properties[​](#lazyseries-properties "Direct link to Properties")

|  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Property Type Description|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `name` str Series name|  |  |  | | --- | --- | --- | | `dtype` dtype Data type | | | | | | | | |

### Methods[​](#lazyseries-methods "Direct link to Methods")

Inherits most methods from `ColumnExpr`. Key methods:

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method Description|  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `value_counts()` Value frequencies|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `unique()` Unique values|  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `nunique()` Count unique|  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | | `mode()` Mode value|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `to_list()` Convert to list|  |  |  |  | | --- | --- | --- | --- | | `to_numpy()` Convert to array|  |  | | --- | --- | | `to_frame()` Convert to DataStore | | | | | | | | | | | | | | | |

---

## Related Classes[​](#related "Direct link to Related Classes")

### F (Functions)[​](#f-class "Direct link to F (Functions)")

Namespace for ClickHouse functions.

```
from chdb.datastore import F, Field

# Aggregations
F.sum(Field('amount'))
F.avg(Field('price'))
F.count(Field('id'))
F.quantile(Field('value'), 0.95)

# Conditional
F.sum_if(Field('amount'), Field('status') == 'completed')
F.count_if(Field('active'))

# Window
F.row_number().over(order_by='date')
F.lag('price', 1).over(partition_by='product', order_by='date')
```

See [Aggregation](/docs/chdb/datastore/aggregation#f-namespace) for details.

### Field[​](#field-class "Direct link to Field")

Reference to a column by name.

```
from chdb.datastore import Field

# Create field reference
amount = Field('amount')
price = Field('price')

# Use in expressions
F.sum(Field('amount'))
F.avg(Field('price'))
```

### CaseWhen[​](#casewhen-class "Direct link to CaseWhen")

Builder for CASE WHEN expressions.

```
# Create case-when expression
result = (ds
    .when(ds['score'] >= 90, 'A')
    .when(ds['score'] >= 80, 'B')
    .when(ds['score'] >= 70, 'C')
    .otherwise('F')
)

# Assign to column
ds['grade'] = result
```

### Window[​](#window-class "Direct link to Window")

Window specification for window functions.

```
from chdb.datastore import F

# Create window
window = F.window(
    partition_by='category',
    order_by='date',
    rows_between=(-7, 0)
)

# Use with aggregation
ds['rolling_avg'] = F.avg('price').over(window)
```

- [DataStore](#datastore)
  - [Constructor](#datastore-constructor)- [Properties](#datastore-properties)- [Factory Methods](#datastore-factory)- [Query Methods](#datastore-query)- [Pandas-compatible methods](#datastore-pandas)- [I/O Methods](#datastore-io)- [Debugging Methods](#datastore-debug)- [Magic Methods](#datastore-magic)- [ColumnExpr](#columnexpr)
    - [Properties](#columnexpr-properties)- [Accessors](#columnexpr-accessors)- [Arithmetic Operations](#columnexpr-arithmetic)- [Comparison Operations](#columnexpr-comparison)- [Logical Operations](#columnexpr-logical)- [Methods](#columnexpr-methods)- [Aggregation Methods](#columnexpr-aggregation)- [LazyGroupBy](#lazygroupby)
      - [Methods](#lazygroupby-methods)- [Column Selection](#lazygroupby-columns)- [Aggregation Specifications](#lazygroupby-agg)- [LazySeries](#lazyseries)
        - [Properties](#lazyseries-properties)- [Methods](#lazyseries-methods)- [Related Classes](#related)
          - [F (Functions)](#f-class)- [Field](#field-class)- [CaseWhen](#casewhen-class)- [Window](#window-class)

Was this page helpful?