andbeonetraveler
andbeonetraveler

Reputation: 725

Pandas concatenate all elements of dataframe into single series

There must be a simple answer to this, but for some reason I can't find it. Apologies if this is a duplicate question.

I have a dataframe with shape on the order of (1000,100). I want to concatenate ALL items in the dataframe into a single series (or list). Order doesn't matter (so it doesn't matter what axis to concatenate along). I don't want/need to keep any column names or indices. Dropping NaNs and duplicates is ok but not required.

What's the easiest way to do this?

Upvotes: 3

Views: 989

Answers (1)

Jeff
Jeff

Reputation: 128928

This will yield a 1-dim numpy-array of the lowest-common dtype for all elements.

df.values.ravel()

Upvotes: 4

Related Questions