Reputation: 89
Pls let me know Pandas in excel.
A B C
0 1 4 7
1 2 5 8
2 3 6 9
I want to select B column value 4, 5, 6
and paste to another excel sheet with row direction. Please help me,,
B 4 5 6
Upvotes: 0
Views: 604
Reputation: 153500
Try this. Use column filtering to select 'B' then convert the pd.Series to a dataframe using to_frame
and then transpose, T. Lastly, use to_excel
:
df['B'].to_frame().T.to_excel('b.xlsx')
Output:
Use startrow
and startcol
parameters:
df['B'].to_frame().T.to_excel('b1.xlsx', startrow=2, startcol=2)
Output:
df['B'].to_frame().T.to_excel('b3.xlsx', startrow=2, startcol=2, sheet_name='SheetNew')
Upvotes: 2