0

I have a pandas dataframe of 3 columns by 5 rows. I would like to make it be one column of 15 rows by putting the second column below the first, and the third below the second. Something like:

[1,2,3,
 4,5,6,
 7,8,9,
 10,11,12,
 13,14,15]

would turn into:

[1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15]

Is there a cleaner, quicker way to do this than calling df.append multiple times? In reality I will have to do this for dozens of columns, not just three.

Tim Starr
  • 39
  • 6

1 Answers1

0
df.to_numpy().flatten()

will do exactly this

Tim Starr
  • 39
  • 6