SparseArray is an ExtensionArray #22325
High-level summary: SparseArray is an ExtensionArray. It's no longer an ndarray subclass. The actual data model hasn't changed at all, it's still an array and a
This isn't really close to being ready yet. I'm going to go through and self-review a bunch of things right now, will call out for others' opinions in specific places.
NumPy will do that for us, but it still takes a different path (on older numpy).
I think it's roughly equivalent to
In : a = np.array([0, 1, 2]) In : a[[True, False, True]] /Users/taugspurger/miniconda3/envs/circle-27-compat/bin/ipython:1: FutureWarning: in the future, boolean array-likes will be handled as a boolean array index #!/Users/taugspurger/miniconda3/envs/circle-27-compat/bin/python Out: array([1, 0, 1])
Oh, I see what you're suggesting. I only see two of these FutureWarnings from numpy...
Looking at quantile, right now it'd be fine to convert the ExtensionArray mask to an ndarray because we know that
The other case is in SparseArray.take, where we create the ndarray, so that's safe.
Sorry forgot to post what I found. The LOC is
return self.take(np.arange(len(key), dtype=np.int32)[key])
We can't hit that with an SparseArray (we go to dense earlier). I see now that we're hitting it with something like
In : arr[[True, False, True]] pandas/core/sparse/array.py:662: FutureWarning: in the future, boolean array-likes will be handled as a boolean array index return self.take(np.arange(len(key), dtype=np.int32)[key]) Out: [2, 1, 2] Fill: 0 IntIndex Indices: array([0, 1, 2], dtype=int32)
again this is only on older numpys. So we can do an asarray on key there.