[Python] Find the closest location between two dataframes based on distance

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have two dataframes, the first one has the longitude and latitude for the meters, and the second dataframe has the longitude and latitude of the stations.

    I am trying to link them by closest match.

    Here is my example:

    df_id = pd.DataFrame({
    'id': [1, 2],
    'lat': [32, 55],
    'long': [-89, -8]
    })


    df_station = pd.DataFrame({
    'id': [10, 20],
    'lat': [33, 56],
    'long': [-88.23, -7]
    })


    and here is the expected output:

    [​IMG]

    Continue reading...

Compartilhe esta Página