mardi 1 mai 2018

infinite loop when double looping

I've got two csv files, df1 which has postcodes only and df which has postcodes and their corresponding longitude and latitude values.

import numpy as np
from math import radians, sqrt, sin, cos, atan2
import pandas as pd
import matplotlib.pyplot as plt


df = pd.read_csv("C:/Users///UKPostcodes.csv")
df1 = pd.read_csv("C:/Users///postcode.csv")


X = df['outcode'].values
lat = df['latitude'].values
lon = df['longitude'].values

find = df1['Postcode District'].values

longitude = []

for i in range(0, len(find)):
    for j in range(0, len(X)):

        if find[i] == X[j]:
            print(find[i])
            #longitude.append(float(lon[j]));

I'm trying to loop through both files and find all of the longitude and latitude for df1, at the moment it runs an infinite loop, any idea how I can do this for all the values in my df1 file only and terminate once that limit has been reached?

Aucun commentaire:

Enregistrer un commentaire