Other distances: dist.*
haversine
Returns haversine distance between two structs with the keys latitude, longitude.
Example
df = pl.DataFrame(
{
"x": [{"latitude": 38.898556, "longitude": -77.037852}],
"y": [{"latitude": 38.897147, "longitude": -77.043934}],
}
)
df.select(pld.col('x').dist.haversine('y', 'km').alias('haversine'))
shape: (1, 1)
┌───────────┐
│ haversine │
│ --- │
│ f64 │
╞═══════════╡
│ 0.549156 │
└───────────┘