Reputation: 185
why this (1):
lst = ['a', 'b', 'c', 'd', 'a', 'b', 'd']
df = pd.DataFrame(lst)
df
gives this output:
0
0 a
1 b
2 c
3 d
4 a
5 b
6 d
but this (2)
chars = 'A A A A A A A A A A B B B B B C C C C C C C C C D D D D D D D E E E E E F F F G G G G G H H H H'
df = pd.DataFrame([chars.split()])
df
gives this output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
0 A A A A A A A A A A B B B B B C C C C C C C C C D D D D D D D E E E E E F F F G G G G G H H H H
How can I have only one column in the (2) output please?
Upvotes: 1
Views: 318
Reputation: 13349
This will give you the desired output:
df = pd.DataFrame(chars.split())
Upvotes: 1