|
27 | 27 | is_datetime64_any_dtype, is_datetime64tz_dtype,
|
28 | 28 | is_timedelta64_dtype, is_datetimelike,
|
29 | 29 | is_interval_dtype, is_scalar, is_list_like,
|
30 |
| - _ensure_platform_int, _ensure_object, |
31 |
| - _ensure_float64, _ensure_uint64, |
32 |
| - _ensure_int64) |
| 30 | + ensure_platform_int, ensure_object, |
| 31 | + ensure_float64, ensure_uint64, |
| 32 | + ensure_int64) |
33 | 33 | from pandas.compat.numpy import _np_version_under1p10
|
34 | 34 | from pandas.core.dtypes.missing import isna, na_value_for_dtype
|
35 | 35 |
|
@@ -73,32 +73,32 @@ def _ensure_data(values, dtype=None):
|
73 | 73 | # we check some simple dtypes first
|
74 | 74 | try:
|
75 | 75 | if is_object_dtype(dtype):
|
76 |
| - return _ensure_object(np.asarray(values)), 'object', 'object' |
| 76 | + return ensure_object(np.asarray(values)), 'object', 'object' |
77 | 77 | if is_bool_dtype(values) or is_bool_dtype(dtype):
|
78 | 78 | # we are actually coercing to uint64
|
79 | 79 | # until our algos support uint8 directly (see TODO)
|
80 | 80 | return np.asarray(values).astype('uint64'), 'bool', 'uint64'
|
81 | 81 | elif is_signed_integer_dtype(values) or is_signed_integer_dtype(dtype):
|
82 |
| - return _ensure_int64(values), 'int64', 'int64' |
| 82 | + return ensure_int64(values), 'int64', 'int64' |
83 | 83 | elif (is_unsigned_integer_dtype(values) or
|
84 | 84 | is_unsigned_integer_dtype(dtype)):
|
85 |
| - return _ensure_uint64(values), 'uint64', 'uint64' |
| 85 | + return ensure_uint64(values), 'uint64', 'uint64' |
86 | 86 | elif is_float_dtype(values) or is_float_dtype(dtype):
|
87 |
| - return _ensure_float64(values), 'float64', 'float64' |
| 87 | + return ensure_float64(values), 'float64', 'float64' |
88 | 88 | elif is_object_dtype(values) and dtype is None:
|
89 |
| - return _ensure_object(np.asarray(values)), 'object', 'object' |
| 89 | + return ensure_object(np.asarray(values)), 'object', 'object' |
90 | 90 | elif is_complex_dtype(values) or is_complex_dtype(dtype):
|
91 | 91 |
|
92 | 92 | # ignore the fact that we are casting to float
|
93 | 93 | # which discards complex parts
|
94 | 94 | with catch_warnings(record=True):
|
95 |
| - values = _ensure_float64(values) |
| 95 | + values = ensure_float64(values) |
96 | 96 | return values, 'float64', 'float64'
|
97 | 97 |
|
98 | 98 | except (TypeError, ValueError):
|
99 | 99 | # if we are trying to coerce to a dtype
|
100 | 100 | # and it is incompat this will fall thru to here
|
101 |
| - return _ensure_object(values), 'object', 'object' |
| 101 | + return ensure_object(values), 'object', 'object' |
102 | 102 |
|
103 | 103 | # datetimelike
|
104 | 104 | if (needs_i8_conversion(values) or
|
@@ -129,13 +129,13 @@ def _ensure_data(values, dtype=None):
|
129 | 129 |
|
130 | 130 | # we are actually coercing to int64
|
131 | 131 | # until our algos support int* directly (not all do)
|
132 |
| - values = _ensure_int64(values) |
| 132 | + values = ensure_int64(values) |
133 | 133 |
|
134 | 134 | return values, dtype, 'int64'
|
135 | 135 |
|
136 | 136 | # we have failed, return object
|
137 | 137 | values = np.asarray(values)
|
138 |
| - return _ensure_object(values), 'object', 'object' |
| 138 | + return ensure_object(values), 'object', 'object' |
139 | 139 |
|
140 | 140 |
|
141 | 141 | def _reconstruct_data(values, dtype, original):
|
@@ -475,7 +475,7 @@ def _factorize_array(values, na_sentinel=-1, size_hint=None,
|
475 | 475 | labels = table.get_labels(values, uniques, 0, na_sentinel,
|
476 | 476 | na_value=na_value)
|
477 | 477 |
|
478 |
| - labels = _ensure_platform_int(labels) |
| 478 | + labels = ensure_platform_int(labels) |
479 | 479 | uniques = uniques.to_array()
|
480 | 480 | return labels, uniques
|
481 | 481 |
|
@@ -1309,7 +1309,7 @@ def _take_nd_object(arr, indexer, out, axis, fill_value, mask_info):
|
1309 | 1309 | if arr.dtype != out.dtype:
|
1310 | 1310 | arr = arr.astype(out.dtype)
|
1311 | 1311 | if arr.shape[axis] > 0:
|
1312 |
| - arr.take(_ensure_platform_int(indexer), axis=axis, out=out) |
| 1312 | + arr.take(ensure_platform_int(indexer), axis=axis, out=out) |
1313 | 1313 | if needs_masking:
|
1314 | 1314 | outindexer = [slice(None)] * arr.ndim
|
1315 | 1315 | outindexer[axis] = mask
|
@@ -1450,7 +1450,7 @@ def _get_take_nd_function(ndim, arr_dtype, out_dtype, axis=0, mask_info=None):
|
1450 | 1450 | return func
|
1451 | 1451 |
|
1452 | 1452 | def func(arr, indexer, out, fill_value=np.nan):
|
1453 |
| - indexer = _ensure_int64(indexer) |
| 1453 | + indexer = ensure_int64(indexer) |
1454 | 1454 | _take_nd_object(arr, indexer, out, axis=axis, fill_value=fill_value,
|
1455 | 1455 | mask_info=mask_info)
|
1456 | 1456 |
|
@@ -1609,7 +1609,7 @@ def take_nd(arr, indexer, axis=0, out=None, fill_value=np.nan, mask_info=None,
|
1609 | 1609 | indexer = np.arange(arr.shape[axis], dtype=np.int64)
|
1610 | 1610 | dtype, fill_value = arr.dtype, arr.dtype.type()
|
1611 | 1611 | else:
|
1612 |
| - indexer = _ensure_int64(indexer, copy=False) |
| 1612 | + indexer = ensure_int64(indexer, copy=False) |
1613 | 1613 | if not allow_fill:
|
1614 | 1614 | dtype, fill_value = arr.dtype, arr.dtype.type()
|
1615 | 1615 | mask_info = None, False
|
@@ -1687,11 +1687,11 @@ def take_2d_multi(arr, indexer, out=None, fill_value=np.nan, mask_info=None,
|
1687 | 1687 | if row_idx is None:
|
1688 | 1688 | row_idx = np.arange(arr.shape[0], dtype=np.int64)
|
1689 | 1689 | else:
|
1690 |
| - row_idx = _ensure_int64(row_idx) |
| 1690 | + row_idx = ensure_int64(row_idx) |
1691 | 1691 | if col_idx is None:
|
1692 | 1692 | col_idx = np.arange(arr.shape[1], dtype=np.int64)
|
1693 | 1693 | else:
|
1694 |
| - col_idx = _ensure_int64(col_idx) |
| 1694 | + col_idx = ensure_int64(col_idx) |
1695 | 1695 | indexer = row_idx, col_idx
|
1696 | 1696 | if not allow_fill:
|
1697 | 1697 | dtype, fill_value = arr.dtype, arr.dtype.type()
|
|
0 commit comments