1

I have a pandas dataframe in the following format:

Latitude    Longiutde
53.553      -80.3123
58.1211     -81.3245

I am trying to convert this dataframe to a list of lists to use it in my plotting package.

[[53.553, -80.3123], [58.1211, -81.3245]]

I tried with iterating through the pandas rows to append these columns to a list but for some reason I am not even able to make my first level list.

list.append(row['Latitude'], row['Longitude'])

Any help would be appreciated.

1 Answer 1

5

use the tolist method on the underlying numpy array

df

enter image description here

df.values.tolist()

[[53.553000000000004, -80.3123], [58.1211, -81.3245]]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.