@@ -1068,7 +1068,7 @@ def to_panel(self):
1068
1068
to_wide = deprecate ('to_wide' , to_panel )
1069
1069
1070
1070
def to_csv (self , path_or_buf = None , sep = "," , na_rep = '' , float_format = None ,
1071
- cols = None , header = True , index = True , index_label = None ,
1071
+ columns = None , header = True , index = True , index_label = None ,
1072
1072
mode = 'w' , nanRep = None , encoding = None , quoting = None ,
1073
1073
quotechar = '"' , line_terminator = '\n ' , chunksize = None ,
1074
1074
tupleize_cols = False , date_format = None , doublequote = True ,
@@ -1086,7 +1086,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
1086
1086
Missing data representation
1087
1087
float_format : string, default None
1088
1088
Format string for floating point numbers
1089
- cols : sequence, optional
1089
+ columns : sequence, optional
1090
1090
Columns to write
1091
1091
header : boolean or list of string, default True
1092
1092
Write out column names. If a list of string is given it is assumed
@@ -1124,17 +1124,29 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
1124
1124
or new (expanded format) if False)
1125
1125
date_format : string, default None
1126
1126
Format string for datetime objects
1127
+ cols : kwarg only alias of columns [deprecated]
1127
1128
"""
1128
1129
if nanRep is not None : # pragma: no cover
1129
1130
warnings .warn ("nanRep is deprecated, use na_rep" ,
1130
1131
FutureWarning )
1131
1132
na_rep = nanRep
1132
1133
1134
+ # Parse old-style keyword argument
1135
+ cols = kwds .pop ('cols' , None )
1136
+ if cols is not None :
1137
+ warnings .warn ("cols is deprecated, use columns" , FutureWarning )
1138
+ if columns is None :
1139
+ columns = cols
1140
+ else :
1141
+ msg = "Can only specify either 'columns' or 'cols'"
1142
+ raise TypeError (msg )
1143
+
1144
+
1133
1145
formatter = fmt .CSVFormatter (self , path_or_buf ,
1134
1146
line_terminator = line_terminator ,
1135
1147
sep = sep , encoding = encoding ,
1136
1148
quoting = quoting , na_rep = na_rep ,
1137
- float_format = float_format , cols = cols ,
1149
+ float_format = float_format , cols = columns ,
1138
1150
header = header , index = index ,
1139
1151
index_label = index_label , mode = mode ,
1140
1152
chunksize = chunksize , quotechar = quotechar ,
@@ -1149,9 +1161,9 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
1149
1161
return formatter .path_or_buf .getvalue ()
1150
1162
1151
1163
def to_excel (self , excel_writer , sheet_name = 'Sheet1' , na_rep = '' ,
1152
- float_format = None , cols = None , header = True , index = True ,
1164
+ float_format = None , columns = None , header = True , index = True ,
1153
1165
index_label = None , startrow = 0 , startcol = 0 , engine = None ,
1154
- merge_cells = True , encoding = None ):
1166
+ merge_cells = True , encoding = None , ** kwds ):
1155
1167
"""
1156
1168
Write DataFrame to a excel sheet
1157
1169
@@ -1189,6 +1201,7 @@ def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
1189
1201
encoding: string, default None
1190
1202
encoding of the resulting excel file. Only necessary for xlwt,
1191
1203
other writers support unicode natively.
1204
+ cols : kwarg only alias of columns [deprecated]
1192
1205
1193
1206
Notes
1194
1207
-----
@@ -1202,6 +1215,17 @@ def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
1202
1215
>>> writer.save()
1203
1216
"""
1204
1217
from pandas .io .excel import ExcelWriter
1218
+
1219
+ # Parse old-style keyword argument
1220
+ cols = kwds .pop ('cols' , None )
1221
+ if cols is not None :
1222
+ warnings .warn ("cols is deprecated, use columns" , FutureWarning )
1223
+ if columns is None :
1224
+ columns = cols
1225
+ else :
1226
+ msg = "Can only specify either 'columns' or 'cols'"
1227
+ raise TypeError (msg )
1228
+
1205
1229
need_save = False
1206
1230
if encoding == None :
1207
1231
encoding = 'ascii'
@@ -1212,7 +1236,7 @@ def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
1212
1236
1213
1237
formatter = fmt .ExcelFormatter (self ,
1214
1238
na_rep = na_rep ,
1215
- cols = cols ,
1239
+ cols = columns ,
1216
1240
header = header ,
1217
1241
float_format = float_format ,
1218
1242
index = index ,
0 commit comments