title_wip

```
# IP operations
ds['is_valid_ip'] = ds['ip'].ip.is_ipv4_string()
ds['ip_num'] = ds['ip'].ip.ipv4_string_to_num()
```

---

## Geo Accessor (`.geo`)[​](#geo "Direct link to geo")

ClickHouse-specific geo/distance operations (14 methods).

### Distance Functions[​](#geo-distance "Direct link to Distance Functions")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method ClickHouse Description|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `great_circle_distance(...)` `greatCircleDistance()` Great circle distance|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `geo_distance(...)` `geoDistance()` WGS-84 distance|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `l1_distance(v1, v2)` `L1Distance()` Manhattan distance|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `l2_distance(v1, v2)` `L2Distance()` Euclidean distance|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `l2_squared_distance(v1, v2)` `L2SquaredDistance()` Squared Euclidean|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `linf_distance(v1, v2)` `LinfDistance()` Chebyshev distance|  |  |  | | --- | --- | --- | | `cosine_distance(v1, v2)` `cosineDistance()` Cosine distance | | | | | | | | | | | | | | | | | | | | | | | |

### Vector Operations[​](#geo-vector "Direct link to Vector Operations")

|  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method ClickHouse Description|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `dot_product(v1, v2)` `dotProduct()` Dot product|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `l2_norm(vec)` `L2Norm()` Vector norm|  |  |  | | --- | --- | --- | | `l2_normalize(vec)` `L2Normalize()` Normalize | | | | | | | | | | | |

### H3 Functions[​](#geo-h3 "Direct link to H3 Functions")

|  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method ClickHouse Description|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `geo_to_h3(lon, lat, res)` `geoToH3()` Geo to H3 index|  |  |  | | --- | --- | --- | | `h3_to_geo(h3)` `h3ToGeo()` H3 to geo coords | | | | | | | | |

### Point Operations[​](#geo-point "Direct link to Point Operations")

|  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method ClickHouse Description|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `point_in_polygon(pt, poly)` `pointInPolygon()` Point in polygon|  |  |  | | --- | --- | --- | | `point_in_ellipses(...)` `pointInEllipses()` Point in ellipses | | | | | | | | |

```
from chdb.datastore import F

# Calculate distances
ds['distance'] = F.great_circle_distance(
    ds['lon1'], ds['lat1'],
    ds['lon2'], ds['lat2']
)

# Vector similarity
ds['similarity'] = F.cosine_distance(ds['embedding1'], ds['embedding2'])
```

---

## Using Accessors[​](#using-accessors "Direct link to Using Accessors")

### Lazy Evaluation[​](#lazy "Direct link to Lazy Evaluation")

Most accessor methods are lazy - they return expressions that are evaluated later:

```
# All these are lazy
ds['name_upper'] = ds['name'].str.upper()  # Not executed yet
ds['year'] = ds['date'].dt.year            # Not executed yet
ds['domain'] = ds['url'].url.domain()      # Not executed yet

# Execution happens when you access results
df = ds.to_df()  # Now everything executes
```

### Methods That Execute Immediately[​](#execute-immediately "Direct link to Methods That Execute Immediately")

Some `.str` methods must execute because they change the structure:

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method Returns Why|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `partition(sep)` DataStore (3 columns) Creates multiple columns|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `rpartition(sep)` DataStore (3 columns) Creates multiple columns|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `get_dummies(sep)` DataStore (N columns) Dynamic column count|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `extractall(pat)` DataStore MultiIndex result|  |  |  | | --- | --- | --- | | `cat(sep)` str Aggregation (N rows → 1) | | | | | | | | | | | | | | | | | |

### Chaining Accessors[​](#chaining "Direct link to Chaining Accessors")

Accessor methods can be chained:

```
ds['clean_name'] = (ds['name']
    .str.strip()
    .str.lower()
    .str.replace(' ', '_')
)

ds['next_month_start'] = (ds['date']
    .dt.add_months(1)
    .dt.to_start_of_month()
)
```

- [String Accessor (`.str`)](#str)
  - [Case Conversion](#str-case)- [Length and Size](#str-length)- [Substring and Slicing](#str-substring)- [Trimming](#str-trim)- [Search and Match](#str-search)- [Replace](#str-replace)- [Splitting](#str-split)- [Padding](#str-padding)- [Character Tests](#str-tests)- [Other](#str-other)- [DateTime Accessor (`.dt`)](#dt)
    - [Date Components](#dt-components)- [Truncation](#dt-truncation)- [Arithmetic](#dt-arithmetic)- [Boolean Checks](#dt-checks)- [Formatting](#dt-formatting)- [Timezone](#dt-timezone)- [Array Accessor (`.arr`)](#arr)
      - [Properties](#arr-properties)- [Element Access](#arr-access)- [Aggregations](#arr-aggregations)- [Transformations](#arr-transformations)- [Modifications](#arr-modifications)- [Search](#arr-search)- [String Operations](#arr-string)- [JSON Accessor (`.json`)](#json)- [URL Accessor (`.url`)](#url)- [IP Accessor (`.ip`)](#ip)- [Geo Accessor (`.geo`)](#geo)
              - [Distance Functions](#geo-distance)- [Vector Operations](#geo-vector)- [H3 Functions](#geo-h3)- [Point Operations](#geo-point)- [Using Accessors](#using-accessors)
                - [Lazy Evaluation](#lazy)- [Methods That Execute Immediately](#execute-immediately)- [Chaining Accessors](#chaining)

Was this page helpful?