4242 klass = "Panel" ,
4343 axes_single_arg = "{0, 1, 2, 'items', 'major_axis', 'minor_axis'}" ,
4444 optional_mapper = '' , optional_axis = '' , optional_labels = '' )
45- _shared_doc_kwargs ['args_transpose' ] = ("three positional arguments: each one"
46- " of\n %s" %
47- _shared_doc_kwargs ['axes_single_arg' ])
45+ _shared_doc_kwargs ['args_transpose' ] = (
46+ "three positional arguments: each one of\n {ax_single}" . format (
47+ ax_single = _shared_doc_kwargs ['axes_single_arg' ]) )
4848
4949
5050def _ensure_like_indices (time , panels ):
@@ -311,7 +311,8 @@ def _init_matrix(self, data, axes, dtype=None, copy=False):
311311 try :
312312 values = values .astype (dtype )
313313 except Exception :
314- raise ValueError ('failed to cast to %s' % dtype )
314+ raise ValueError ('failed to cast to '
315+ '{datatype}' .format (datatype = dtype ))
315316
316317 shape = values .shape
317318 fixed_axes = []
@@ -352,18 +353,18 @@ def __unicode__(self):
352353
353354 class_name = str (self .__class__ )
354355
355- shape = self . shape
356- dims = u ( 'Dimensions: %s' ) % ' x ' . join (
357- [ "%d (%s)" % ( s , a ) for a , s in zip (self ._AXIS_ORDERS , shape )])
356+ dims = u ( 'Dimensions: {dimensions}' . format ( dimensions = ' x ' . join (
357+ [ "{shape} ({axis})" . format ( shape = shape , axis = axis ) for axis , shape
358+ in zip (self ._AXIS_ORDERS , self . shape )])) )
358359
359360 def axis_pretty (a ):
360361 v = getattr (self , a )
361362 if len (v ) > 0 :
362- return u ('%s axis: %s to %s' ) % ( a .capitalize (),
363- pprint_thing (v [0 ]),
364- pprint_thing (v [- 1 ]))
363+ return u ('{ax} axis: {x} to {y}' . format ( ax = a .capitalize (),
364+ x = pprint_thing (v [0 ]),
365+ y = pprint_thing (v [- 1 ]) ))
365366 else :
366- return u ('%s axis: None' ) % a .capitalize ()
367+ return u ('{ax} axis: None' . format ( ax = a .capitalize ()) )
367368
368369 output = '\n ' .join (
369370 [class_name , dims ] + [axis_pretty (a ) for a in self ._AXIS_ORDERS ])
@@ -610,7 +611,8 @@ def __setitem__(self, key, value):
610611 elif is_scalar (value ):
611612 mat = cast_scalar_to_array (shape [1 :], value )
612613 else :
613- raise TypeError ('Cannot set item of type: %s' % str (type (value )))
614+ raise TypeError ('Cannot set item of '
615+ 'type: {dtype!s}' .format (dtype = type (value )))
614616
615617 mat = mat .reshape (tuple ([1 ]) + shape [1 :])
616618 NDFrame ._set_item (self , key , mat )
@@ -739,9 +741,9 @@ def _combine(self, other, func, axis=0):
739741 elif is_scalar (other ):
740742 return self ._combine_const (other , func )
741743 else :
742- raise NotImplementedError ("%s is not supported in combine "
743- " operation with %s" %
744- ( str ( type (other )), str ( type (self ) )))
744+ raise NotImplementedError (
745+ "{otype!s} is not supported in combine operation with "
746+ "{selftype!s}" . format ( otype = type (other ), selftype = type (self )))
745747
746748 def _combine_const (self , other , func , try_cast = True ):
747749 with np .errstate (all = 'ignore' ):
@@ -1188,8 +1190,8 @@ def _construct_return_type(self, result, axes=None):
11881190 return self ._constructor_sliced (
11891191 result , ** self ._extract_axes_for_slice (self , axes ))
11901192
1191- raise ValueError ('invalid _construct_return_type [self->%s ] '
1192- '[result->%s]' % (self , result ))
1193+ raise ValueError ('invalid _construct_return_type [self->{self} ] '
1194+ '[result->{result}]' . format (self = self , result = result ))
11931195
11941196 def _wrap_result (self , result , axis ):
11951197 axis = self ._get_axis_name (axis )
@@ -1508,7 +1510,8 @@ def _extract_axis(self, data, axis=0, intersect=False):
15081510 if have_raw_arrays :
15091511 lengths = list (set (raw_lengths ))
15101512 if len (lengths ) > 1 :
1511- raise ValueError ('ndarrays must match shape on axis %d' % axis )
1513+ raise ValueError ('ndarrays must match shape on '
1514+ 'axis {ax}' .format (ax = axis ))
15121515
15131516 if have_frames :
15141517 if lengths [0 ] != len (index ):
@@ -1525,20 +1528,6 @@ def _extract_axis(self, data, axis=0, intersect=False):
15251528 def _add_aggregate_operations (cls , use_numexpr = True ):
15261529 """ add the operations to the cls; evaluate the doc strings again """
15271530
1528- # doc strings substitors
1529- _agg_doc = """
1530- Wrapper method for %%s
1531-
1532- Parameters
1533- ----------
1534- other : %s or %s""" % (cls ._constructor_sliced .__name__ , cls .__name__ ) + """
1535- axis : {""" + ', ' .join (cls ._AXIS_ORDERS ) + "}" + """
1536- Axis to broadcast over
1537-
1538- Returns
1539- -------
1540- """ + cls .__name__ + "\n "
1541-
15421531 def _panel_arith_method (op , name , str_rep = None , default_axis = None ,
15431532 fill_zeros = None , ** eval_kwargs ):
15441533 def na_op (x , y ):
@@ -1566,27 +1555,45 @@ def na_op(x, y):
15661555 equiv = 'panel ' + op_desc ['op' ] + ' other'
15671556
15681557 _op_doc = """
1569- %%s of series and other, element-wise (binary operator `%%s`).
1570- Equivalent to ``%%s``.
1558+ {desc} of series and other, element-wise (binary operator `{op_name}`).
1559+ Equivalent to ``{equiv}``.
1560+
1561+ Parameters
1562+ ----------
1563+ other : {construct} or {cls_name}
1564+ axis : {{{axis_order}}}
1565+ Axis to broadcast over
1566+
1567+ Returns
1568+ -------
1569+ {cls_name}
1570+
1571+ See also
1572+ --------
1573+ {cls_name}.{reverse}\n """
1574+ doc = _op_doc .format (
1575+ desc = op_desc ['desc' ], op_name = op_name , equiv = equiv ,
1576+ construct = cls ._constructor_sliced .__name__ ,
1577+ cls_name = cls .__name__ , reverse = op_desc ['reverse' ],
1578+ axis_order = ', ' .join (cls ._AXIS_ORDERS ))
1579+ else :
1580+ # doc strings substitors
1581+ _agg_doc = """
1582+ Wrapper method for {wrp_method}
15711583
15721584 Parameters
15731585 ----------
1574- other : %s or %s""" % (cls ._constructor_sliced .__name__ ,
1575- cls .__name__ ) + """
1576- axis : {""" + ', ' .join (cls ._AXIS_ORDERS ) + "}" + """
1586+ other : {construct} or {cls_name}
1587+ axis : {{{axis_order}}}
15771588 Axis to broadcast over
15781589
15791590 Returns
15801591 -------
1581- """ + cls .__name__ + """
1582-
1583- See also
1584- --------
1585- """ + cls .__name__ + ".%s\n "
1586- doc = _op_doc % (op_desc ['desc' ], op_name , equiv ,
1587- op_desc ['reverse' ])
1588- else :
1589- doc = _agg_doc % name
1592+ {cls_name}\n """
1593+ doc = _agg_doc .format (
1594+ construct = cls ._constructor_sliced .__name__ ,
1595+ cls_name = cls .__name__ , wrp_method = name ,
1596+ axis_order = ', ' .join (cls ._AXIS_ORDERS ))
15901597
15911598 @Appender (doc )
15921599 def f (self , other , axis = 0 ):
0 commit comments