@@ -267,7 +267,7 @@ def _construct_axes_from_arguments(self, args, kwargs, require_all=False):
267
267
raise TypeError (
268
268
"not enough/duplicate arguments specified!" )
269
269
270
- axes = dict ([(a , kwargs .get ( a )) for a in self ._AXIS_ORDERS ])
270
+ axes = dict ([(a , kwargs .pop ( a , None )) for a in self ._AXIS_ORDERS ])
271
271
return axes , kwargs
272
272
273
273
@classmethod
@@ -444,8 +444,13 @@ def transpose(self, *args, **kwargs):
444
444
new_axes = self ._construct_axes_dict_from (
445
445
self , [self ._get_axis (x ) for x in axes_names ])
446
446
new_values = self .values .transpose (axes_numbers )
447
- if kwargs .get ('copy' ) or (len (args ) and args [- 1 ]):
447
+ if kwargs .pop ('copy' , None ) or (len (args ) and args [- 1 ]):
448
448
new_values = new_values .copy ()
449
+
450
+ if kwargs :
451
+ raise TypeError ('transpose() got an unexpected keyword '
452
+ 'argument "{0}"' .format (list (kwargs .keys ())[0 ]))
453
+
449
454
return self ._constructor (new_values , ** new_axes ).__finalize__ (self )
450
455
451
456
def swapaxes (self , axis1 , axis2 , copy = True ):
@@ -540,8 +545,12 @@ def swaplevel(self, i, j, axis=0):
540
545
def rename (self , * args , ** kwargs ):
541
546
542
547
axes , kwargs = self ._construct_axes_from_arguments (args , kwargs )
543
- copy = kwargs .get ('copy' , True )
544
- inplace = kwargs .get ('inplace' , False )
548
+ copy = kwargs .pop ('copy' , True )
549
+ inplace = kwargs .pop ('inplace' , False )
550
+
551
+ if kwargs :
552
+ raise TypeError ('rename() got an unexpected keyword '
553
+ 'argument "{0}"' .format (list (kwargs .keys ())[0 ]))
545
554
546
555
if (com ._count_not_none (* axes .values ()) == 0 ):
547
556
raise TypeError ('must pass an index to rename' )
@@ -1531,10 +1540,12 @@ def reindex_like(self, other, method=None, copy=True, limit=None):
1531
1540
-------
1532
1541
reindexed : same as input
1533
1542
"""
1534
- d = other ._construct_axes_dict (method = method , copy = copy , limit = limit )
1543
+ d = other ._construct_axes_dict (axes = self ._AXIS_ORDERS ,
1544
+ method = method , copy = copy , limit = limit )
1545
+
1535
1546
return self .reindex (** d )
1536
1547
1537
- def drop (self , labels , axis = 0 , level = None , inplace = False , ** kwargs ):
1548
+ def drop (self , labels , axis = 0 , level = None , inplace = False ):
1538
1549
"""
1539
1550
Return new object with labels in requested axis removed
1540
1551
@@ -1708,11 +1719,15 @@ def reindex(self, *args, **kwargs):
1708
1719
1709
1720
# construct the args
1710
1721
axes , kwargs = self ._construct_axes_from_arguments (args , kwargs )
1711
- method = com ._clean_reindex_fill_method (kwargs .get ('method' ))
1712
- level = kwargs .get ('level' )
1713
- copy = kwargs .get ('copy' , True )
1714
- limit = kwargs .get ('limit' )
1715
- fill_value = kwargs .get ('fill_value' , np .nan )
1722
+ method = com ._clean_reindex_fill_method (kwargs .pop ('method' , None ))
1723
+ level = kwargs .pop ('level' , None )
1724
+ copy = kwargs .pop ('copy' , True )
1725
+ limit = kwargs .pop ('limit' , None )
1726
+ fill_value = kwargs .pop ('fill_value' , np .nan )
1727
+
1728
+ if kwargs :
1729
+ raise TypeError ('reindex() got an unexpected keyword '
1730
+ 'argument "{0}"' .format (list (kwargs .keys ())[0 ]))
1716
1731
1717
1732
self ._consolidate_inplace ()
1718
1733
@@ -1917,7 +1932,7 @@ def tail(self, n=5):
1917
1932
#----------------------------------------------------------------------
1918
1933
# Attribute access
1919
1934
1920
- def __finalize__ (self , other , method = None , ** kwargs ):
1935
+ def __finalize__ (self , other , method = None ):
1921
1936
"""
1922
1937
propagate metadata from other to self
1923
1938
@@ -3422,7 +3437,7 @@ def shift(self, periods=1, freq=None, axis=0, **kwds):
3422
3437
3423
3438
return self ._constructor (new_data ).__finalize__ (self )
3424
3439
3425
- def slice_shift (self , periods = 1 , axis = 0 , ** kwds ):
3440
+ def slice_shift (self , periods = 1 , axis = 0 ):
3426
3441
"""
3427
3442
Equivalent to `shift` without copying data. The shifted data will
3428
3443
not include the dropped periods and the shifted axis will be smaller
@@ -4053,7 +4068,7 @@ def logical_func(self, axis=None, bool_only=None, skipna=None,
4053
4068
desc = "Return the mean absolute deviation of the values "
4054
4069
"for the requested axis" )
4055
4070
@Appender (_num_doc )
4056
- def mad (self , axis = None , skipna = None , level = None , ** kwargs ):
4071
+ def mad (self , axis = None , skipna = None , level = None ):
4057
4072
if skipna is None :
4058
4073
skipna = True
4059
4074
if axis is None :
@@ -4111,7 +4126,7 @@ def stat_func(self, axis=None, skipna=None, level=None, ddof=1,
4111
4126
desc = "Return the compound percentage of the values for "
4112
4127
"the requested axis" )
4113
4128
@Appender (_num_doc )
4114
- def compound (self , axis = None , skipna = None , level = None , ** kwargs ):
4129
+ def compound (self , axis = None , skipna = None , level = None ):
4115
4130
if skipna is None :
4116
4131
skipna = True
4117
4132
return (1 + self ).prod (axis = axis , skipna = skipna , level = level ) - 1
0 commit comments