@@ -2619,6 +2619,72 @@ def to_csv(self, path=None, index=True, sep=",", na_rep='',
2619
2619
if path is None :
2620
2620
return result
2621
2621
2622
+ def to_excel (self , excel_writer , sheet_name = 'Sheet1' , na_rep = '' ,
2623
+ float_format = None , columns = None , header = True , index = True ,
2624
+ index_label = None , startrow = 0 , startcol = 0 , engine = None ,
2625
+ merge_cells = True , encoding = None , inf_rep = 'inf' , verbose = True ):
2626
+ """
2627
+ Write Series to a excel sheet
2628
+
2629
+ Parameters
2630
+ ----------
2631
+ excel_writer : string or ExcelWriter object
2632
+ File path or existing ExcelWriter
2633
+ sheet_name : string, default 'Sheet1'
2634
+ Name of sheet which will contain DataFrame
2635
+ na_rep : string, default ''
2636
+ Missing data representation
2637
+ float_format : string, default None
2638
+ Format string for floating point numbers
2639
+ columns : sequence, optional
2640
+ Columns to write
2641
+ header : boolean or list of string, default True
2642
+ Write out column names. If a list of string is given it is
2643
+ assumed to be aliases for the column names
2644
+ index : boolean, default True
2645
+ Write row names (index)
2646
+ index_label : string or sequence, default None
2647
+ Column label for index column(s) if desired. If None is given, and
2648
+ `header` and `index` are True, then the index names are used. A
2649
+ sequence should be given if the DataFrame uses MultiIndex.
2650
+ startrow :
2651
+ upper left cell row to dump data frame
2652
+ startcol :
2653
+ upper left cell column to dump data frame
2654
+ engine : string, default None
2655
+ write engine to use - you can also set this via the options
2656
+ ``io.excel.xlsx.writer``, ``io.excel.xls.writer``, and
2657
+ ``io.excel.xlsm.writer``.
2658
+ merge_cells : boolean, default True
2659
+ Write MultiIndex and Hierarchical Rows as merged cells.
2660
+ encoding: string, default None
2661
+ encoding of the resulting excel file. Only necessary for xlwt,
2662
+ other writers support unicode natively.
2663
+ inf_rep : string, default 'inf'
2664
+ Representation for infinity (there is no native representation for
2665
+ infinity in Excel)
2666
+
2667
+ Notes
2668
+ -----
2669
+ If passing an existing ExcelWriter object, then the sheet will be added
2670
+ to the existing workbook. This can be used to save different
2671
+ DataFrames to one workbook:
2672
+
2673
+ >>> writer = ExcelWriter('output.xlsx')
2674
+ >>> s.to_excel(writer,'Sheet1')
2675
+ >>> s.to_excel(writer,'Sheet2')
2676
+ >>> writer.save()
2677
+
2678
+ For compatibility with to_csv, to_excel serializes lists and dicts to
2679
+ strings before writing.
2680
+ """
2681
+ from pandas .core .frame import DataFrame
2682
+ df = DataFrame (self )
2683
+ df .to_excel (excel_writer , sheet_name , na_rep ,
2684
+ float_format , columns , header , index ,
2685
+ index_label , startrow , startcol , engine ,
2686
+ merge_cells , encoding , inf_rep , verbose )
2687
+
2622
2688
def dropna (self , axis = 0 , inplace = False , ** kwargs ):
2623
2689
"""
2624
2690
Return Series without null values
0 commit comments