@@ -643,7 +643,8 @@ def _set_axis(self, axis, labels):
643
643
self ._data .set_axis (axis , labels )
644
644
self ._clear_item_cache ()
645
645
646
- _shared_docs ['transpose' ] = """
646
+ def transpose (self , * args , ** kwargs ):
647
+ """
647
648
Permute the dimensions of the %(klass)s
648
649
649
650
Parameters
@@ -663,9 +664,6 @@ def _set_axis(self, axis, labels):
663
664
y : same as input
664
665
"""
665
666
666
- @Appender (_shared_docs ['transpose' ] % _shared_doc_kwargs )
667
- def transpose (self , * args , ** kwargs ):
668
-
669
667
# construct the args
670
668
axes , kwargs = self ._construct_axes_from_arguments (args , kwargs ,
671
669
require_all = True )
@@ -965,23 +963,20 @@ def swaplevel(self, i=-2, j=-1, axis=0):
965
963
# ----------------------------------------------------------------------
966
964
# Rename
967
965
968
- # TODO: define separate funcs for DataFrame, Series and Panel so you can
969
- # get completion on keyword arguments.
970
- _shared_docs ['rename' ] = """
966
+ def rename (self , * args , ** kwargs ):
967
+ """
971
968
Alter axes input function or functions. Function / dict values must be
972
969
unique (1-to-1). Labels not contained in a dict / Series will be left
973
970
as-is. Extra labels listed don't throw an error. Alternatively, change
974
971
``Series.name`` with a scalar value (Series only).
975
972
976
973
Parameters
977
974
----------
978
- %(optional_mapper)s
979
975
%(axes)s : scalar, list-like, dict-like or function, optional
980
976
Scalar or list-like will alter the ``Series.name`` attribute,
981
977
and raise on DataFrame or Panel.
982
978
dict-like or functions are transformations to apply to
983
979
that axis' values
984
- %(optional_axis)s
985
980
copy : boolean, default True
986
981
Also copy underlying data
987
982
inplace : boolean, default False
@@ -1069,12 +1064,6 @@ def swaplevel(self, i=-2, j=-1, axis=0):
1069
1064
1070
1065
See the :ref:`user guide <basics.rename>` for more.
1071
1066
"""
1072
-
1073
- @Appender (_shared_docs ['rename' ] % dict (axes = 'axes keywords for this'
1074
- ' object' , klass = 'NDFrame' ,
1075
- optional_mapper = '' ,
1076
- optional_axis = '' ))
1077
- def rename (self , * args , ** kwargs ):
1078
1067
axes , kwargs = self ._construct_axes_from_arguments (args , kwargs )
1079
1068
copy = kwargs .pop ('copy' , True )
1080
1069
inplace = kwargs .pop ('inplace' , False )
@@ -1127,8 +1116,6 @@ def f(x):
1127
1116
else :
1128
1117
return result .__finalize__ (self )
1129
1118
1130
- rename .__doc__ = _shared_docs ['rename' ]
1131
-
1132
1119
def rename_axis (self , mapper , axis = 0 , copy = True , inplace = False ):
1133
1120
"""
1134
1121
Alter the name of the index or columns.
@@ -3024,7 +3011,8 @@ def __delitem__(self, key):
3024
3011
except KeyError :
3025
3012
pass
3026
3013
3027
- _shared_docs ['_take' ] = """
3014
+ def _take (self , indices , axis = 0 , is_copy = True ):
3015
+ """
3028
3016
Return the elements in the given *positional* indices along an axis.
3029
3017
3030
3018
This means that we are not indexing according to actual values in
@@ -3055,9 +3043,6 @@ def __delitem__(self, key):
3055
3043
numpy.ndarray.take
3056
3044
numpy.take
3057
3045
"""
3058
-
3059
- @Appender (_shared_docs ['_take' ])
3060
- def _take (self , indices , axis = 0 , is_copy = True ):
3061
3046
self ._consolidate_inplace ()
3062
3047
3063
3048
new_data = self ._data .take (indices ,
@@ -3072,7 +3057,8 @@ def _take(self, indices, axis=0, is_copy=True):
3072
3057
3073
3058
return result
3074
3059
3075
- _shared_docs ['take' ] = """
3060
+ def take (self , indices , axis = 0 , convert = None , is_copy = True , ** kwargs ):
3061
+ """
3076
3062
Return the elements in the given *positional* indices along an axis.
3077
3063
3078
3064
This means that we are not indexing according to actual values in
@@ -3155,9 +3141,6 @@ class max_speed
3155
3141
1 monkey mammal NaN
3156
3142
3 lion mammal 80.5
3157
3143
"""
3158
-
3159
- @Appender (_shared_docs ['take' ])
3160
- def take (self , indices , axis = 0 , convert = None , is_copy = True , ** kwargs ):
3161
3144
if convert is not None :
3162
3145
msg = ("The 'convert' parameter is deprecated "
3163
3146
"and will be removed in a future version." )
@@ -3580,7 +3563,9 @@ def add_suffix(self, suffix):
3580
3563
mapper = {self ._info_axis_name : f }
3581
3564
return self .rename (** mapper )
3582
3565
3583
- _shared_docs ['sort_values' ] = """
3566
+ def sort_values (self , by = None , axis = 0 , ascending = True , inplace = False ,
3567
+ kind = 'quicksort' , na_position = 'last' ):
3568
+ """
3584
3569
Sort by the values along either axis
3585
3570
3586
3571
Parameters
@@ -3665,17 +3650,12 @@ def add_suffix(self, suffix):
3665
3650
0 A 2 0
3666
3651
1 A 1 1
3667
3652
"""
3668
-
3669
- def sort_values (self , by = None , axis = 0 , ascending = True , inplace = False ,
3670
- kind = 'quicksort' , na_position = 'last' ):
3671
- """
3672
- NOT IMPLEMENTED: do not call this method, as sorting values is not
3673
- supported for Panel objects and will raise an error.
3674
- """
3675
3653
raise NotImplementedError ("sort_values has not been implemented "
3676
3654
"on Panel or Panel4D objects." )
3677
3655
3678
- _shared_docs ['sort_index' ] = """
3656
+ def sort_index (self , axis = 0 , level = None , ascending = True , inplace = False ,
3657
+ kind = 'quicksort' , na_position = 'last' , sort_remaining = True ):
3658
+ """
3679
3659
Sort object by labels (along an axis)
3680
3660
3681
3661
Parameters
@@ -3703,10 +3683,6 @@ def sort_values(self, by=None, axis=0, ascending=True, inplace=False,
3703
3683
-------
3704
3684
sorted_obj : %(klass)s
3705
3685
"""
3706
-
3707
- @Appender (_shared_docs ['sort_index' ] % dict (axes = "axes" , klass = "NDFrame" ))
3708
- def sort_index (self , axis = 0 , level = None , ascending = True , inplace = False ,
3709
- kind = 'quicksort' , na_position = 'last' , sort_remaining = True ):
3710
3686
inplace = validate_bool_kwarg (inplace , 'inplace' )
3711
3687
axis = self ._get_axis_number (axis )
3712
3688
axis_name = self ._get_axis_name (axis )
@@ -3724,7 +3700,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
3724
3700
new_axis = labels .take (sort_index )
3725
3701
return self .reindex (** {axis_name : new_axis })
3726
3702
3727
- _shared_docs ['reindex' ] = """
3703
+ def reindex (self , * args , ** kwargs ):
3704
+ """
3728
3705
Conform %(klass)s to new index with optional filling logic, placing
3729
3706
NA/NaN in locations having no value in the previous index. A new object
3730
3707
is produced unless the new index is equivalent to the current one and
@@ -3920,14 +3897,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
3920
3897
-------
3921
3898
reindexed : %(klass)s
3922
3899
"""
3923
-
3924
- # TODO: Decide if we care about having different examples for different
3925
- # kinds
3926
-
3927
- @Appender (_shared_docs ['reindex' ] % dict (axes = "axes" , klass = "NDFrame" ,
3928
- optional_labels = "" ,
3929
- optional_axis = "" ))
3930
- def reindex (self , * args , ** kwargs ):
3900
+ # TODO: Decide if we care about having different examples for different
3901
+ # kinds
3931
3902
3932
3903
# construct the args
3933
3904
axes , kwargs = self ._construct_axes_from_arguments (args , kwargs )
0 commit comments