0

I have a long list:

input_data = [a, b, c, d, e, f, g, h, ...]

How can I to split them by their index number into:

  type1.  type2.  type3.  type4.
0.  a       b       c       d
1.  e       f       g       h
2.  ...
sooon
  • 4,718
  • 8
  • 63
  • 116

1 Answers1

3

Try with reshape

n = 2#you can change to n = 4
out = pd.DataFrame(np.array(input).reshape((-1,n)))
Out[45]: 
   0  1
0  a  b
1  c  d
BENY
  • 317,841
  • 20
  • 164
  • 234