4141from pandas .compat import (range , zip , lrange , lmap , lzip , StringIO , u ,
4242 OrderedDict , raise_with_traceback )
4343from pandas import compat
44- from pandas .util .decorators import deprecate , Appender , Substitution
44+ from pandas .util .decorators import deprecate , Appender , Substitution , \
45+ deprecate_kwarg
4546
4647from pandas .tseries .period import PeriodIndex
4748from pandas .tseries .index import DatetimeIndex
@@ -1067,8 +1068,9 @@ def to_panel(self):
10671068
10681069 to_wide = deprecate ('to_wide' , to_panel )
10691070
1071+ @deprecate_kwarg (old_arg_name = 'cols' , new_arg_name = 'columns' )
10701072 def to_csv (self , path_or_buf = None , sep = "," , na_rep = '' , float_format = None ,
1071- cols = None , header = True , index = True , index_label = None ,
1073+ columns = None , header = True , index = True , index_label = None ,
10721074 mode = 'w' , nanRep = None , encoding = None , quoting = None ,
10731075 quotechar = '"' , line_terminator = '\n ' , chunksize = None ,
10741076 tupleize_cols = False , date_format = None , doublequote = True ,
@@ -1086,7 +1088,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
10861088 Missing data representation
10871089 float_format : string, default None
10881090 Format string for floating point numbers
1089- cols : sequence, optional
1091+ columns : sequence, optional
10901092 Columns to write
10911093 header : boolean or list of string, default True
10921094 Write out column names. If a list of string is given it is assumed
@@ -1124,6 +1126,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
11241126 or new (expanded format) if False)
11251127 date_format : string, default None
11261128 Format string for datetime objects
1129+ cols : kwarg only alias of columns [deprecated]
11271130 """
11281131 if nanRep is not None : # pragma: no cover
11291132 warnings .warn ("nanRep is deprecated, use na_rep" ,
@@ -1134,7 +1137,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
11341137 line_terminator = line_terminator ,
11351138 sep = sep , encoding = encoding ,
11361139 quoting = quoting , na_rep = na_rep ,
1137- float_format = float_format , cols = cols ,
1140+ float_format = float_format , cols = columns ,
11381141 header = header , index = index ,
11391142 index_label = index_label , mode = mode ,
11401143 chunksize = chunksize , quotechar = quotechar ,
@@ -1148,8 +1151,9 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
11481151 if path_or_buf is None :
11491152 return formatter .path_or_buf .getvalue ()
11501153
1154+ @deprecate_kwarg (old_arg_name = 'cols' , new_arg_name = 'columns' )
11511155 def to_excel (self , excel_writer , sheet_name = 'Sheet1' , na_rep = '' ,
1152- float_format = None , cols = None , header = True , index = True ,
1156+ float_format = None , columns = None , header = True , index = True ,
11531157 index_label = None , startrow = 0 , startcol = 0 , engine = None ,
11541158 merge_cells = True , encoding = None ):
11551159 """
@@ -1189,6 +1193,7 @@ def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
11891193 encoding: string, default None
11901194 encoding of the resulting excel file. Only necessary for xlwt,
11911195 other writers support unicode natively.
1196+ cols : kwarg only alias of columns [deprecated]
11921197
11931198 Notes
11941199 -----
@@ -1202,6 +1207,7 @@ def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
12021207 >>> writer.save()
12031208 """
12041209 from pandas .io .excel import ExcelWriter
1210+
12051211 need_save = False
12061212 if encoding == None :
12071213 encoding = 'ascii'
@@ -1212,7 +1218,7 @@ def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
12121218
12131219 formatter = fmt .ExcelFormatter (self ,
12141220 na_rep = na_rep ,
1215- cols = cols ,
1221+ cols = columns ,
12161222 header = header ,
12171223 float_format = float_format ,
12181224 index = index ,
@@ -2439,27 +2445,28 @@ def dropna(self, axis=0, how='any', thresh=None, subset=None,
24392445 else :
24402446 return result
24412447
2442- def drop_duplicates (self , cols = None , take_last = False , inplace = False ):
2448+ @deprecate_kwarg (old_arg_name = 'cols' , new_arg_name = 'subset' )
2449+ def drop_duplicates (self , subset = None , take_last = False , inplace = False ):
24432450 """
24442451 Return DataFrame with duplicate rows removed, optionally only
24452452 considering certain columns
24462453
24472454 Parameters
24482455 ----------
2449- cols : column label or sequence of labels, optional
2456+ subset : column label or sequence of labels, optional
24502457 Only consider certain columns for identifying duplicates, by
24512458 default use all of the columns
24522459 take_last : boolean, default False
24532460 Take the last observed row in a row. Defaults to the first row
24542461 inplace : boolean, default False
24552462 Whether to drop duplicates in place or to return a copy
2463+ cols : kwargs only argument of subset [deprecated]
24562464
24572465 Returns
24582466 -------
24592467 deduplicated : DataFrame
24602468 """
2461-
2462- duplicated = self .duplicated (cols , take_last = take_last )
2469+ duplicated = self .duplicated (subset , take_last = take_last )
24632470
24642471 if inplace :
24652472 inds , = (- duplicated ).nonzero ()
@@ -2468,18 +2475,20 @@ def drop_duplicates(self, cols=None, take_last=False, inplace=False):
24682475 else :
24692476 return self [- duplicated ]
24702477
2471- def duplicated (self , cols = None , take_last = False ):
2478+ @deprecate_kwarg (old_arg_name = 'cols' , new_arg_name = 'subset' )
2479+ def duplicated (self , subset = None , take_last = False ):
24722480 """
24732481 Return boolean Series denoting duplicate rows, optionally only
24742482 considering certain columns
24752483
24762484 Parameters
24772485 ----------
2478- cols : column label or sequence of labels, optional
2486+ subset : column label or sequence of labels, optional
24792487 Only consider certain columns for identifying duplicates, by
24802488 default use all of the columns
24812489 take_last : boolean, default False
24822490 Take the last observed row in a row. Defaults to the first row
2491+ cols : kwargs only argument of subset [deprecated]
24832492
24842493 Returns
24852494 -------
@@ -2491,19 +2500,19 @@ def _m8_to_i8(x):
24912500 return x .view (np .int64 )
24922501 return x
24932502
2494- if cols is None :
2503+ if subset is None :
24952504 values = list (_m8_to_i8 (self .values .T ))
24962505 else :
2497- if np .iterable (cols ) and not isinstance (cols , compat .string_types ):
2498- if isinstance (cols , tuple ):
2499- if cols in self .columns :
2500- values = [self [cols ].values ]
2506+ if np .iterable (subset ) and not isinstance (subset , compat .string_types ):
2507+ if isinstance (subset , tuple ):
2508+ if subset in self .columns :
2509+ values = [self [subset ].values ]
25012510 else :
2502- values = [_m8_to_i8 (self [x ].values ) for x in cols ]
2511+ values = [_m8_to_i8 (self [x ].values ) for x in subset ]
25032512 else :
2504- values = [_m8_to_i8 (self [x ].values ) for x in cols ]
2513+ values = [_m8_to_i8 (self [x ].values ) for x in subset ]
25052514 else :
2506- values = [self [cols ].values ]
2515+ values = [self [subset ].values ]
25072516
25082517 keys = lib .fast_zip_fillna (values )
25092518 duplicated = lib .duplicated (keys , take_last = take_last )
0 commit comments