Haversine, module not callable

36 views Asked by At

I want to use a function from haversine. I installed the Haversine package (terminal: pip install haversine) but I can't run it.

import gurobipy as gp
from gurobipy import GRB
import random
import pandas as pd
from math import radians, sin, cos, sqrt, atan2
from haversine import haversine

# Read the first Excel file with your coordinates

first_df = pd.read_excel("Coordinatengroo!.xlsx")

# Extract latitude and longitude columns (assuming 0-based indexing)

latitude_column = first_df.iloc[:, 1]
longitude_column = first_df.iloc[:, 2]

# Convert latitude and longitude columns to lists

latitude_values = latitude_column.tolist()
longitude_values = longitude_column.tolist()

new_df = pd.read_excel("gas_stations_coordinates_excluding_friesland.xlsx")

# Extract latitude and longitude columns (assuming 0-based indexing)

new_latitude_column = new_df.iloc[:, 1]  # Change 0 to the correct column index
new_longitude_column = new_df.iloc[:, 2]  # Change 1 to the correct column index

# Convert latitude and longitude columns to lists

new_latitude_values = new_latitude_column.tolist()
new_longitude_values = new_longitude_column.tolist()

# Compute distances

distances = {}

for i in range (0, len(new_latitude_values)):
    for j in range (0, len(latitude_values)):
        distances[(i,j)] = haversine((new_latitude_values[i], new_longitude_values[i]), (latitude_values[j], longitude_values[j]))

When I run it, I get:

File "/etc/", line 38, in <module>
distances[(i,j)] = haversine((new_latitude_values[i], new_longitude_values[i]), (latitude_values[j], longitude_values[j]))
TypeError: 'module' object is not callable

Process finished with exit code 1

I tried downloading it again. It's not working.

0

There are 0 answers