write column to csv python

Solutions on MaxInterview for write column to csv python by the best coders in the world

showing results for - "write column to csv python"
Silvia
16 Apr 2017
1import pandas as pd
2
3list1 = [1, 2, 3]
4list2 = [4, 5, 6]
5list3 = [7, 8, 9]
6
7df = pd.DataFrame(list(zip(*[list1, list2, list3]))).add_prefix('Col')
8
9df.to_csv('file.csv', index=False)
10
11print(df)
12
13   Col0  Col1  Col2
140     1     4     7
151     2     5     8
162     3     6     9