The pandas.Series object does have many to_* functions, yet it lacks a to_excel
function. Is there an easier/better way to accomplish the export in line 3 of th
You can either:
DataFrame
from the start,in which case you've already answered your own question.
Series.to_frame()
s.to_frame(name='column_name').to_excel('xlfile.xlsx', sheet_name='s')
Beginning with pandas version 0.20, Series now supports to_excel
directly (see PR #8825 for details):
import pandas as pd
s = pd.Series([0, 1, 2, 4, 8, 16], name='a_series')
s.to_excel('foo.xlsx')
Contents of file foo.xlsx:
| A | B |
--+----+-----------+---------------------
1 | | a_series |
2 | 0 | 0 |
3 | 1 | 1 |
4 | 2 | 2 |
5 | 3 | 4 |
6 | 4 | 8 |
7 | 5 | 16 |
-. ,---------------------------
\ Sheet 1 / \ Sheet 2 / \ Sheet 3 /