1

I would like to collect the values of the first column of a pandas dataframe into an array. How can I accomplish this?

So far I have tried this:

first_column_values = df.iloc[:,[0]]

But it is not the result I wish to have.

1 Answer 1

2

You're close. It should be:

first_column_values = df.iloc[:, 0].values

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! and on an unrelated note, you have a cool title, "water resources engineer".

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.