I have a table with the following format:
data = {'City' : ['London', 'Paris', 'Paris','NY' 'London'], 'Distance' : [5, 1, 7, 2, 6]}
df = pd.DataFrame(data)
df
City Distance
0 London 5
1 Paris 1
2 Paris 7
3 NY 2
4 London 6
I want to create a table with all rows with a unique 'City', and whenever there are 2 or more rows with the same 'City' value, I would like it to return the one with the lowest 'Distance'. So in this case I wanted a table like this:
City Distance
London 5
Paris 1
NY 2
I know I can use:
df.groupby('City')
But I don't know what to add to it to return the smallest 'Distance'.
Best, Rosa