Question: I have one array and i want to convert it into certain shape which I do not know how to do.

I tried, but it does not give me proper result.

Here is the array-:
this is a numpy array

```
a=[[ [1,2,13],
     [12,2,32],
     [61,2,6],
     [1,23,3],
     [1,21,3],
     [91,2,38] ]]

```

expected outputs-:

```
1. [[ [1,2],
      [12,2],
      [61,2],
      [1,23],
      [1,21], 
      [91,2] ]]

2.  [ [1,2],
       [12,2],
       [61,2],
       [1,23],
       [1,21],
       [91,2] ]

```

Answer: 
I could not get `vincenty` to work, apparently it has been superseded by `geodesic`. But this should work:

```
from geopy.distance import geodesic

df = pd.DataFrame({
    'id': [1,1,1,2,2],
    'lat': [41.144540, 41.144540, 41.163172, 41.163233, 41.163198],
    'lon': [-8.562926, -8.562926, -8.583821, -8.583838, -8.583886   ] 
})

res = (df.groupby(by='id').agg(start_lat=pd.NamedAgg(column='lat', aggfunc='first'), 
                              start_long=pd.NamedAgg(column='lon', aggfunc='first'),
                              end_lat = pd.NamedAgg(column='lat', aggfunc='last'), 
                              end_long=pd.NamedAgg(column='lon', aggfunc='last'))
        .apply(lambda f: geodesic((f['start_lat'], f['start_long']), (f['end_lat'], f['end_long'])), axis=1)
        .reset_index()
        )

df = df.merge(res, on='id').rename(columns={0: 'dist'})

print(df)

```
You can get the first and last values in a single command using `groupby()` and [`agg()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.aggregate.html) (aka `aggregate()`):

```
df.groupby('id').agg({'lat': ['first', 'last'], 'lon': ['first', 'last']})

```

That gives you:

```
          lat                  lon          
        first       last     first      last
id                                          
1   41.144540  41.163172 -8.562926 -8.583821
2   41.163233  41.163198 -8.583838 -8.583886

```

Which is almost exactly what you need to feed to `vincenty()` to compute the distances for each `id`.