input must be an array, list, tuple or scalar pyproj

I Have a DF in which I am trying to convert the eastings/northings to long/lats. My df looks like this:

import pandas as pd
import numpy as np
import pyproj

    Postcode    Eastings    Northings
0   AB101AB     394235      806529
1   AB101AF     394181      806429
2   AB101AG     394230      806469
3   AB101AH     394371      806359
4   AB101AL     394296      806581

I am using a well know code block to convert the eastings and northings to long/lats and add those long/lats as new columns to the df:

def proj_transform(df):
    bng = pyproj.Proj("+init=EPSG:27700")
    wgs84 = pyproj.Proj("+init=EPSG:4326")
    lats = pd.Series()
    lons = pd.Series()
    for idx, val in enumerate(df['Eastings']):
        lon, lat = pyproj.transform(bng, wgs84, df['Eastings'][idx], df['Northings'][idx])
        lats.set_value(idx, lat)
        lons.set_value(idx, lon)
    df['lat'] = lats
    df['lon'] = lons
    return df

df_transform = proj_transform(my_df)

However, I keep getting the following error, "input must be an array, list, tuple or scalar". Does anyone have any insight into where I am going wrong here?



Read more here: https://stackoverflow.com/questions/65700333/input-must-be-an-array-list-tuple-or-scalar-pyproj

Content Attribution

This content was originally published by Amen_90 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: