@@ -5816,23 +5816,25 @@ def clip(self, a_min, a_max, out=None):
5816
5816
from larray .core .ufuncs import clip
5817
5817
return clip (self , a_min , a_max , out )
5818
5818
5819
- def to_csv (self , filepath , sep = ',' , na_rep = '' , transpose = True , dropna = None , dialect = 'default' , ** kwargs ):
5819
+ @deprecate_kwarg ('transpose' , 'wide' )
5820
+ def to_csv (self , filepath , sep = ',' , na_rep = '' , wide = True , dropna = None , dialect = 'default' , ** kwargs ):
5820
5821
"""
5821
5822
Writes array to a csv file.
5822
5823
5823
5824
Parameters
5824
5825
----------
5825
5826
filepath : str
5826
5827
path where the csv file has to be written.
5827
- sep : str
5828
- seperator for the csv file.
5829
- na_rep : str
5830
- replace NA values with na_rep.
5831
- transpose : boolean
5832
- transpose = True => transpose over last axis.
5833
- transpose = False => no transpose.
5834
- dialect : 'default' | 'classic'
5835
- Whether or not to write the last axis name (using '\' )
5828
+ sep : str, optional
5829
+ separator for the csv file. Defaults to `,`.
5830
+ na_rep : str, optional
5831
+ replace NA values with na_rep. Defaults to ''.
5832
+ wide : boolean, optional
5833
+ Whether or not writing arrays in "wide" format. If True, arrays are exported with the last axis
5834
+ represented horizontally. If False, arrays are exported in "narrow" format: one column per axis plus one
5835
+ value column. Defaults to True.
5836
+ dialect : 'default' | 'classic', optional
5837
+ Whether or not to write the last axis name (using '\' ). Defaults to 'default'.
5836
5838
dropna : None, 'all', 'any' or True, optional
5837
5839
Drop lines if 'all' its values are NA, if 'any' value is NA or do not drop any line (default).
5838
5840
True is equivalent to 'all'.
@@ -5852,7 +5854,7 @@ def to_csv(self, filepath, sep=',', na_rep='', transpose=True, dropna=None, dial
5852
5854
nat\\ sex,M,F
5853
5855
BE,0,1
5854
5856
FO,2,3
5855
- >>> a.to_csv(fname, sep=';', transpose =False)
5857
+ >>> a.to_csv(fname, sep=';', wide =False)
5856
5858
>>> with open(fname) as f:
5857
5859
... print(f.read().strip())
5858
5860
nat;sex;0
@@ -5868,7 +5870,7 @@ def to_csv(self, filepath, sep=',', na_rep='', transpose=True, dropna=None, dial
5868
5870
FO,2,3
5869
5871
"""
5870
5872
fold = dialect == 'default'
5871
- if transpose :
5873
+ if wide :
5872
5874
frame = self .to_frame (fold , dropna )
5873
5875
frame .to_csv (filepath , sep = sep , na_rep = na_rep , ** kwargs )
5874
5876
else :
@@ -5900,7 +5902,7 @@ def to_hdf(self, filepath, key, *args, **kwargs):
5900
5902
self .to_frame ().to_hdf (filepath , key , * args , ** kwargs )
5901
5903
5902
5904
def to_excel (self , filepath = None , sheet_name = None , position = 'A1' , overwrite_file = False , clear_sheet = False ,
5903
- header = True , transpose = False , engine = None , * args , ** kwargs ):
5905
+ header = True , transpose = False , wide = True , engine = None , * args , ** kwargs ):
5904
5906
"""
5905
5907
Writes array in the specified sheet of specified excel workbook.
5906
5908
@@ -5923,8 +5925,12 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
5923
5925
header : bool, optional
5924
5926
Whether or not to write a header (axes names and labels). Defaults to True.
5925
5927
transpose : bool, optional
5926
- Whether or not to transpose the resulting array. This can be used, for example, for writing one dimensional
5927
- arrays vertically. Defaults to False.
5928
+ Whether or not to transpose the array transpose over last axis.
5929
+ This is equivalent to paste with option transpose in Excel. Defaults to False.
5930
+ wide : boolean, optional
5931
+ Whether or not writing arrays in "wide" format. If True, arrays are exported with the last axis
5932
+ represented horizontally. If False, arrays are exported in "narrow" format: one column per axis plus one
5933
+ value column. Defaults to True.
5928
5934
engine : 'xlwings' | 'openpyxl' | 'xlsxwriter' | 'xlwt' | None, optional
5929
5935
Engine to use to make the output. If None (default), it will use 'xlwings' by default if the module is
5930
5936
installed and relies on Pandas default writer otherwise.
@@ -5943,7 +5949,11 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
5943
5949
"""
5944
5950
sheet_name = _translate_sheet_name (sheet_name )
5945
5951
5946
- df = self .to_frame (fold_last_axis_name = True )
5952
+ if wide :
5953
+ pd_obj = self .to_frame (fold_last_axis_name = True )
5954
+ else :
5955
+ pd_obj = self .to_series ()
5956
+
5947
5957
if engine is None :
5948
5958
engine = 'xlwings' if xw is not None else None
5949
5959
@@ -5977,7 +5987,7 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
5977
5987
sheet = wb .sheets .add (sheet_name , after = wb .sheets [- 1 ])
5978
5988
5979
5989
options = dict (header = header , index = header , transpose = transpose )
5980
- sheet [position ].options (** options ).value = df
5990
+ sheet [position ].options (** options ).value = pd_obj
5981
5991
# TODO: implement transpose via/in dump
5982
5992
# sheet[position] = self.dump(header=header, transpose=transpose)
5983
5993
if close :
@@ -5988,7 +5998,7 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
5988
5998
sheet_name = 'Sheet1'
5989
5999
# TODO: implement position in this case
5990
6000
# startrow, startcol
5991
- df .to_excel (filepath , sheet_name , * args , engine = engine , ** kwargs )
6001
+ pd_obj .to_excel (filepath , sheet_name , * args , engine = engine , ** kwargs )
5992
6002
5993
6003
def to_clipboard (self , * args , ** kwargs ):
5994
6004
"""Sends the content of the array to clipboard.
0 commit comments