raw_data.append([parsed_json["_id"], parsed_json["name"], parsed_json["coord"]["lat"], parsed_json["coord"]["lon"]])

# Create df from file
cities_df = pd.DataFrame(raw_data, columns=["api_id", "name", "lat", "long"])    
#cities_df = pd.read_csv(path, header=0, sep=",")

cities_df["lat"] = cities_df["lat"].convert_objects(convert_numeric=True)
cities_df["long"] = cities_df["long"].convert_objects(convert_numeric=True)

radius = 4
offset = 4

# Get coordinates as they will be displayed on the cube
coord_list = []
for i in range(len(cities_df)):
    x, x_r, y, y_r, z, z_r = testPoint(cities_df.ix[i]["lat"], cities_df.ix[i]["long"], radius, offset=offset)
    coord = int(str(x_r)+str(y_r)+str(z_r))
    coord_list.append(coord)
    
cities_df["coord"] = coord_list

# Get coordinates for which duplicates exist 
# (it will take some time if you're using the api's json)
duplicates = list_duplicates(coord_list)

# print all duplicates and choose a random city between them
# delete others from df
# (comment print statements if analyzing json)
for value in duplicates:
    dup_group = cities_df[cities_df["coord"]==value]
#    print(dup_group)
##Testing how distance affects result 
r = 4

# how latitude/longitude variation affects x
# for latitude put i in first position and 0 for 2nd
# for longitude put 0 in first position and long for 2nd
raw_x = []
rounded_x = []
raw_y = []
rounded_y = []
raw_z = []
rounded_z = []

for i in range(-180, 181):
    x, r_x, y, r_y, z, r_z = testPoint(i, 0, r, offset=4)
    raw_x.append(x)
    rounded_x.append(r_x)
    raw_y.append(y)
    rounded_y.append(r_y)    
    raw_z.append(z)
    rounded_z.append(r_z)
    
x = np.arange(-180, 181, 1)

plt.plot(x, raw_x, color="#0000FF", label="x")
plt.scatter(x, rounded_x, color="#58ACFA", marker="s", label="round(x)")
plt.plot(x, raw_y, color="#DF0101", label="y")
plt.scatter(x, rounded_y, color="#F78181", marker="s", label="round(y)")
plt.plot(x, raw_z, color="#DF01D7", label="z")
plt.scatter(x, rounded_z, color="#F5A9D0", marker="s", label="round(z)")