python
12 lines · 1 tab
Dr. Elena Vasquez
Apr 2026
1 tab
import geopandas as gpd
from shapely.geometry import Point
stores = gpd.read_file('stores.geojson').to_crs(epsg=3857)
customers = gpd.GeoDataFrame(
customer_df,
geometry=[Point(xy) for xy in zip(customer_df.longitude, customer_df.latitude)],
crs='EPSG:4326',
).to_crs(epsg=3857)
nearest_store = gpd.sjoin_nearest(customers, stores[['store_id', 'geometry']], how='left', distance_col='distance_meters')
print(nearest_store[['customer_id', 'store_id', 'distance_meters']].head())
1 file · python
Explain with highlit
Location data becomes useful when spatial joins and distance-based features are handled correctly. GeoPandas is enough for many routing, service coverage, and market analysis tasks before you need heavier GIS infrastructure. I care about coordinate systems first because almost every mistake starts there.
Related snips
python
from django.db.models import F, Window
from django.db.models.functions import RowNumber, Rank, DenseRank
from products.models import Sale
def get_sales_with_ranking():
Django ORM window functions for analytics
django
python
database
by Priya Sharma
1 tab
ruby
class ShardedCounter
SHARDS = 16
SNAPSHOT_TTL = 10 # seconds
def initialize(name, redis: REDIS)
@name = name
Lock-Free Read Pattern for Hot Counters (Approximate)
rails
redis
performance
by codesnips
3 tabs
sql
-- Install PostGIS extension
CREATE EXTENSION IF NOT EXISTS postgis;
-- Create table with geometry column
CREATE TABLE locations (
id SERIAL PRIMARY KEY,
Geospatial data with PostGIS
postgresql
postgis
geospatial
by Maria Garcia
2 tabs
sql
-- ROW_NUMBER: Unique sequential number
SELECT
name,
department,
salary,
ROW_NUMBER() OVER (ORDER BY salary DESC) as overall_rank,
Window functions for advanced analytics
sql
window-functions
analytics
by Maria Garcia
2 tabs
python
import pandas as pd
import plotly.express as px
df = pd.read_csv('marketing_performance.csv')
fig = px.scatter(
df,
Interactive Plotly figures for exploratory stakeholder reviews
plotly
dashboards
interactive-visualization
by Dr. Elena Vasquez
1 tab
sql
WITH ordered_events AS (
SELECT
customer_id,
event_time,
revenue,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY event_time DESC) AS event_rank,
SQL window functions for feature extraction and behavioral ranking
sql
window-functions
feature-engineering
by Dr. Elena Vasquez
1 tab
Share this code
Here's the card — post it anywhere.