Skip to content

Commit 5f4143e

Browse files
committed
REF: start refactoring to make Index not an ndarray subclass
1 parent 9faec82 commit 5f4143e

File tree

5 files changed

+217
-215
lines changed

5 files changed

+217
-215
lines changed

pandas/core/common.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def _get_take_1d_function(dtype, out_dtype):
428428
except KeyError:
429429
pass
430430

431-
if dtype != out_dtype:
431+
if dtype != out_dtype:
432432
try:
433433
func = _take_1d_dict[out_dtype.name, out_dtype.name]
434434
return _convert_wrapper(func, out_dtype)
@@ -454,7 +454,7 @@ def _get_take_2d_function(dtype, out_dtype, axis=0):
454454
except KeyError:
455455
pass
456456

457-
if dtype != out_dtype:
457+
if dtype != out_dtype:
458458
try:
459459
if axis == 0:
460460
func = _take_2d_axis0_dict[out_dtype.name, out_dtype.name]
@@ -686,7 +686,7 @@ def _maybe_upcast(values):
686686
elif issubclass(values.dtype.type, np.bool_):
687687
values = values.astype(np.object_)
688688
return values
689-
689+
690690

691691
def _interp_wrapper(f, wrap_dtype, na_override=None):
692692
def wrapper(arr, mask, limit=None):
@@ -824,7 +824,7 @@ def _possibly_convert_objects(values, convert_dates=True, convert_numeric=True):
824824
if values.dtype == np.object_ and convert_numeric:
825825
try:
826826
new_values = lib.maybe_convert_numeric(values,set(),coerce_numeric=True)
827-
827+
828828
# if we are all nans then leave me alone
829829
if not isnull(new_values).all():
830830
values = new_values
@@ -923,9 +923,7 @@ def _is_bool_indexer(key):
923923
def _default_index(n):
924924
from pandas.core.index import Int64Index
925925
values = np.arange(n, dtype=np.int64)
926-
result = values.view(Int64Index)
927-
result.name = None
928-
return result
926+
return Int64Index(values)
929927

930928

931929
def ensure_float(arr):
@@ -1072,7 +1070,7 @@ def _long_prod(vals):
10721070
result *= x
10731071
return result
10741072

1075-
1073+
10761074
class groupby(dict):
10771075
"""
10781076
A simple groupby different from the one in itertools.
@@ -1137,10 +1135,10 @@ def _shift_indexer(N, periods):
11371135
def _asarray_tuplesafe(values, dtype=None):
11381136
from pandas.core.index import Index
11391137

1140-
if not isinstance(values, (list, tuple, np.ndarray)):
1141-
values = list(values)
1142-
elif isinstance(values, Index):
1138+
if isinstance(values, Index):
11431139
return values.values
1140+
elif not isinstance(values, (list, tuple, np.ndarray)):
1141+
values = list(values)
11441142

11451143
if isinstance(values, list) and dtype in [np.object_, object]:
11461144
return lib.list_to_object_array(values)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy