Here provides a solution to do non-pairwise distance calculation between two geopandas dataframes (gdf). However, the outcome distance matrix only preserves index from the two gdf, which may not readable. I add some columns to the gdf as following and then get the distance matrix:
import pandas as pd
import geopandas as gpd
gdf_1 = gpd.GeoDataFrame(geometry=gpd.points_from_xy([0, 0, 0], [0, 90, 120]))
gdf_2 = gpd.GeoDataFrame(geometry=gpd.points_from_xy([0, 0], [0, -90]))
home = ['home_1', 'home_2', 'home_3']
shop = ['shop_1', 'shop_2']
gdf_1['home'] = home
gdf_2['shop'] = shop
gdf_1.geometry.apply(lambda g: gdf_2.distance(g))
As the above table shows, nothing from the original gdf is preserved in the outcome except for the index, which may not intuitive and useful. I was wondering how to preserve all the original columns from both gdf in the outcome distance matrix, or at least keep the "home", "shop", and "distance" columns like this:
Please note: "distance" is the distance measure from home to shop, and the other "geometry" column may need a suffix