Reputation: 15
I have a Excel sheet containing data as shown below where A,B,C,D,E,F,G,H represents Column name in the excel sheet.
A B C D E F G H
Rahul e34 Pradeep e44 Azhar t54 Pavan e24
Venkat r45 Akash e14 Vipul r15 Fairo e45
Akshay e44 Vivek e99 Kumar e55 Asad t14
I want the entire data in two columns A and B as shown below.
Rahul e34
Pradeep e44
Azhar t54
Pavan e24
Venkat r45
Akash e14
Vipul r15
Fairo e45
Akshay e44
Vivek e99
Kumar e55
Asad t14
How do i do using Pandas, Can anyone assist me please.
Upvotes: 0
Views: 358
Reputation: 28729
Reshape the data, using numpy, to get a 2 column format :
pd.DataFrame(np.reshape(df.to_numpy(),(-1,2)))
0 1
0 Rahul e34
1 Pradeep e44
2 Azhar t54
3 Pavan e24
4 Venkat r45
5 Akash e14
6 Vipul r15
7 Fairo e45
8 Akshay e44
9 Vivek e99
10 Kumar e55
11 Asad t14
Upvotes: 2