Skip to content

Commit 0c2c2ef

Browse files
committed
Merge pull request #8406 from sh9189/bbopensrcday2
CLN: Remove core/array.py
2 parents e487a30 + b9bc371 commit 0c2c2ef

File tree

4 files changed

+44
-84
lines changed

4 files changed

+44
-84
lines changed

pandas/core/array.py

-37
This file was deleted.

pandas/core/common.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from pandas.compat import StringIO, BytesIO, range, long, u, zip, map
2323

2424
from pandas.core.config import get_option
25-
from pandas.core import array as pa
2625

2726
class PandasError(Exception):
2827
pass
@@ -999,7 +998,7 @@ def _infer_dtype_from_scalar(val):
999998
dtype = np.object_
1000999

10011000
# a 1-element ndarray
1002-
if isinstance(val, pa.Array):
1001+
if isinstance(val, np.ndarray):
10031002
if val.ndim != 0:
10041003
raise ValueError(
10051004
"invalid ndarray passed to _infer_dtype_from_scalar")
@@ -1350,7 +1349,7 @@ def _fill_zeros(result, x, y, name, fill):
13501349

13511350
if not isinstance(y, np.ndarray):
13521351
dtype, value = _infer_dtype_from_scalar(y)
1353-
y = pa.empty(result.shape, dtype=dtype)
1352+
y = np.empty(result.shape, dtype=dtype)
13541353
y.fill(value)
13551354

13561355
if is_integer_dtype(y):
@@ -1575,7 +1574,7 @@ def _interp_limit(invalid, limit):
15751574
inds = np.asarray(xvalues)
15761575
# hack for DatetimeIndex, #1646
15771576
if issubclass(inds.dtype.type, np.datetime64):
1578-
inds = inds.view(pa.int64)
1577+
inds = inds.view(np.int64)
15791578

15801579
if inds.dtype == np.object_:
15811580
inds = lib.maybe_convert_objects(inds)

pandas/core/ops.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import pandas.index as _index
1313
from pandas.util.decorators import Appender
1414
import pandas.core.common as com
15-
import pandas.core.array as pa
1615
import pandas.computation.expressions as expressions
1716
from pandas.core.common import(bind_method, is_list_like, notnull, isnull,
1817
_values_from_object, _maybe_match_name)
@@ -332,7 +331,7 @@ def _convert_to_array(self, values, name=None, other=None):
332331
# a datelike
333332
elif isinstance(values, pd.DatetimeIndex):
334333
values = values.to_series()
335-
elif not (isinstance(values, (pa.Array, pd.Series)) and
334+
elif not (isinstance(values, (np.ndarray, pd.Series)) and
336335
com.is_datetime64_dtype(values)):
337336
values = tslib.array_to_datetime(values)
338337
elif inferred_type in ('timedelta', 'timedelta64'):
@@ -349,7 +348,7 @@ def _convert_to_array(self, values, name=None, other=None):
349348
"operation [{0}]".format(name))
350349
elif isinstance(values[0], pd.DateOffset):
351350
# handle DateOffsets
352-
os = pa.array([getattr(v, 'delta', None) for v in values])
351+
os = np.array([getattr(v, 'delta', None) for v in values])
353352
mask = isnull(os)
354353
if mask.any():
355354
raise TypeError("cannot use a non-absolute DateOffset in "
@@ -366,10 +365,10 @@ def _convert_to_array(self, values, name=None, other=None):
366365
else:
367366
raise TypeError(
368367
'incompatible type [{0}] for a datetime/timedelta '
369-
'operation'.format(pa.array(values).dtype))
368+
'operation'.format(np.array(values).dtype))
370369
else:
371370
raise TypeError("incompatible type [{0}] for a datetime/timedelta"
372-
" operation".format(pa.array(values).dtype))
371+
" operation".format(np.array(values).dtype))
373372

374373
return values
375374

@@ -408,7 +407,7 @@ def _convert_for_datetime(self, lvalues, rvalues):
408407
if mask is not None:
409408
if mask.any():
410409
def f(x):
411-
x = pa.array(x, dtype=self.dtype)
410+
x = np.array(x, dtype=self.dtype)
412411
np.putmask(x, mask, self.fill_value)
413412
return x
414413
self.wrap_results = f
@@ -449,19 +448,19 @@ def na_op(x, y):
449448
result = expressions.evaluate(op, str_rep, x, y,
450449
raise_on_error=True, **eval_kwargs)
451450
except TypeError:
452-
if isinstance(y, (pa.Array, pd.Series, pd.Index)):
451+
if isinstance(y, (np.ndarray, pd.Series, pd.Index)):
453452
dtype = np.find_common_type([x.dtype, y.dtype], [])
454453
result = np.empty(x.size, dtype=dtype)
455454
mask = notnull(x) & notnull(y)
456455
result[mask] = op(x[mask], _values_from_object(y[mask]))
457-
elif isinstance(x, pa.Array):
458-
result = pa.empty(len(x), dtype=x.dtype)
456+
elif isinstance(x, np.ndarray):
457+
result = np.empty(len(x), dtype=x.dtype)
459458
mask = notnull(x)
460459
result[mask] = op(x[mask], y)
461460
else:
462461
raise TypeError("{typ} cannot perform the operation {op}".format(typ=type(x).__name__,op=str_rep))
463462

464-
result, changed = com._maybe_upcast_putmask(result, ~mask, pa.NA)
463+
result, changed = com._maybe_upcast_putmask(result, ~mask, np.nan)
465464

466465
result = com._fill_zeros(result, x, y, name, fill_zeros)
467466
return result
@@ -531,7 +530,7 @@ def na_op(x, y):
531530
if isinstance(y, list):
532531
y = lib.list_to_object_array(y)
533532

534-
if isinstance(y, (pa.Array, pd.Series)):
533+
if isinstance(y, (np.ndarray, pd.Series)):
535534
if y.dtype != np.object_:
536535
result = lib.vec_compare(x, y.astype(np.object_), op)
537536
else:
@@ -558,7 +557,7 @@ def wrapper(self, other):
558557
index=self.index, name=name)
559558
elif isinstance(other, pd.DataFrame): # pragma: no cover
560559
return NotImplemented
561-
elif isinstance(other, (pa.Array, pd.Index)):
560+
elif isinstance(other, (np.ndarray, pd.Index)):
562561
if len(self) != len(other):
563562
raise ValueError('Lengths must match to compare')
564563
return self._constructor(na_op(self.values, np.asarray(other)),
@@ -610,7 +609,7 @@ def na_op(x, y):
610609
if isinstance(y, list):
611610
y = lib.list_to_object_array(y)
612611

613-
if isinstance(y, (pa.Array, pd.Series)):
612+
if isinstance(y, (np.ndarray, pd.Series)):
614613
if (x.dtype == np.bool_ and
615614
y.dtype == np.bool_): # pragma: no cover
616615
result = op(x, y) # when would this be hit?
@@ -688,7 +687,7 @@ def flex_wrapper(self, other, level=None, fill_value=None, axis=0):
688687
self._get_axis_number(axis)
689688
if isinstance(other, pd.Series):
690689
return self._binop(other, op, level=level, fill_value=fill_value)
691-
elif isinstance(other, (pa.Array, pd.Series, list, tuple)):
690+
elif isinstance(other, (np.ndarray, pd.Series, list, tuple)):
692691
if len(other) != len(self):
693692
raise ValueError('Lengths must be equal')
694693
return self._binop(self._constructor(other, self.index), op,
@@ -925,10 +924,10 @@ def na_op(x, y):
925924
except TypeError:
926925

927926
# TODO: might need to find_common_type here?
928-
result = pa.empty(len(x), dtype=x.dtype)
927+
result = np.empty(len(x), dtype=x.dtype)
929928
mask = notnull(x)
930929
result[mask] = op(x[mask], y)
931-
result, changed = com._maybe_upcast_putmask(result, ~mask, pa.NA)
930+
result, changed = com._maybe_upcast_putmask(result, ~mask, np.nan)
932931

933932
result = com._fill_zeros(result, x, y, name, fill_zeros)
934933
return result

0 commit comments

Comments
 (0)