@@ -177,6 +177,7 @@ class NDFrame(PandasObject, SelectionMixin):
177
177
_is_copy = None
178
178
_data : BlockManager
179
179
_attrs : Dict [Optional [Hashable ], Any ]
180
+ _typ : str
180
181
181
182
# ----------------------------------------------------------------------
182
183
# Constructors
@@ -283,71 +284,52 @@ def _constructor_expanddim(self):
283
284
284
285
# ----------------------------------------------------------------------
285
286
# Axis
287
+ _AXIS_ALIASES = {"rows" : 0 }
288
+ _AXIS_IALIASES = {0 : "rows" }
289
+ _stat_axis_number = 0
290
+ _stat_axis_name = "index"
291
+ _ix = None
292
+ _AXIS_ORDERS : List [str ]
293
+ _AXIS_NUMBERS : Dict [str , int ]
294
+ _AXIS_NAMES : Dict [int , str ]
295
+ _AXIS_REVERSED : bool
296
+ _info_axis_number : int
297
+ _info_axis_name : str
298
+ _AXIS_LEN : int
286
299
287
300
@classmethod
288
- def _setup_axes (
289
- cls ,
290
- axes ,
291
- info_axis = None ,
292
- stat_axis = None ,
293
- aliases = None ,
294
- axes_are_reversed = False ,
295
- build_axes = True ,
296
- ns = None ,
297
- docs = None ,
298
- ):
301
+ def _setup_axes (cls , axes : List [str ], docs : Dict [str , str ]):
299
302
"""
300
303
Provide axes setup for the major PandasObjects.
301
304
302
305
Parameters
303
306
----------
304
307
axes : the names of the axes in order (lowest to highest)
305
- info_axis_num : the axis of the selector dimension (int)
306
- stat_axis_num : the number of axis for the default stats (int)
307
- aliases : other names for a single axis (dict)
308
- axes_are_reversed : bool
309
- Whether to treat passed axes as reversed (DataFrame).
310
- build_axes : setup the axis properties (default True)
308
+ docs : docstrings for the axis properties
311
309
"""
310
+ info_axis = len (axes ) - 1
311
+ axes_are_reversed = len (axes ) > 1
312
312
313
313
cls ._AXIS_ORDERS = axes
314
314
cls ._AXIS_NUMBERS = {a : i for i , a in enumerate (axes )}
315
315
cls ._AXIS_LEN = len (axes )
316
- cls ._AXIS_ALIASES = aliases or dict ()
317
- cls ._AXIS_IALIASES = {v : k for k , v in cls ._AXIS_ALIASES .items ()}
318
316
cls ._AXIS_NAMES = dict (enumerate (axes ))
319
317
cls ._AXIS_REVERSED = axes_are_reversed
320
318
321
- # typ
322
- setattr (cls , "_typ" , cls .__name__ .lower ())
323
-
324
- # indexing support
325
- cls ._ix = None
326
-
327
- if info_axis is not None :
328
- cls ._info_axis_number = info_axis
329
- cls ._info_axis_name = axes [info_axis ]
330
-
331
- if stat_axis is not None :
332
- cls ._stat_axis_number = stat_axis
333
- cls ._stat_axis_name = axes [stat_axis ]
319
+ cls ._info_axis_number = info_axis
320
+ cls ._info_axis_name = axes [info_axis ]
334
321
335
322
# setup the actual axis
336
- if build_axes :
337
-
338
- def set_axis (a , i ):
339
- setattr (cls , a , properties .AxisProperty (i , docs .get (a , a )))
340
- cls ._internal_names_set .add (a )
341
-
342
- if axes_are_reversed :
343
- m = cls ._AXIS_LEN - 1
344
- for i , a in cls ._AXIS_NAMES .items ():
345
- set_axis (a , m - i )
346
- else :
347
- for i , a in cls ._AXIS_NAMES .items ():
348
- set_axis (a , i )
323
+ def set_axis (a , i ):
324
+ setattr (cls , a , properties .AxisProperty (i , docs .get (a , a )))
325
+ cls ._internal_names_set .add (a )
349
326
350
- assert not isinstance (ns , dict )
327
+ if axes_are_reversed :
328
+ for i , a in cls ._AXIS_NAMES .items ():
329
+ set_axis (a , 1 - i )
330
+ else :
331
+ for i , a in cls ._AXIS_NAMES .items ():
332
+ set_axis (a , i )
351
333
352
334
def _construct_axes_dict (self , axes = None , ** kwargs ):
353
335
"""Return an axes dictionary for myself."""
@@ -379,19 +361,6 @@ def _construct_axes_from_arguments(
379
361
args = list (args )
380
362
for a in self ._AXIS_ORDERS :
381
363
382
- # if we have an alias for this axis
383
- alias = self ._AXIS_IALIASES .get (a )
384
- if alias is not None :
385
- if a in kwargs :
386
- if alias in kwargs :
387
- raise TypeError (
388
- f"arguments are mutually exclusive for [{ a } ,{ alias } ]"
389
- )
390
- continue
391
- if alias in kwargs :
392
- kwargs [a ] = kwargs .pop (alias )
393
- continue
394
-
395
364
# look for a argument by position
396
365
if a not in kwargs :
397
366
try :
0 commit comments