Python Forum
Split single column to multiple columns - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Split single column to multiple columns (/thread-35992.html)



Split single column to multiple columns - SriRajesh - Jan-07-2022

Hi,
I have pandas.core.Dataframe as below
When I write to csv using df.to_csv it placed in single columns and 8 rows with delimiter as comma(","). First row is A,B,C,D. I want to separate 4by1 to 4by4.
when I type df.columns it give Index([A,B,C,D]).

A,B,C,D
1,2,3,4
5,6,7,8,
9,1,3


RE: Split single column to multiple columns - jefsummers - Jan-07-2022

Need to see your code defining and filling the dataframe to see why it is doing this.