-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate Series._from_array ? #19883
Comments
we don't need to deprecate this, rather remove it. Its almost there. If you can do it w/o breaking things great. |
Sure! If you guys think is worth pursuing, I'll give it a try and see how the test complain! |
great! |
also be sure to check perf on Series creation (using asv) |
Deprecating or removing is a semantic discussion ;), the question is if we can remove it, and how to remove it. Are there differences in behaviour between seies with sparse values and sparse series that would make this backwards incompatible?
Note that this is not the same (it gives a series with dense values, not a series with sparse values) |
After going through the code a bit, I've found a simplified way to fix this that would not imply going into result = self._constructor_sliced._from_array(
values, index=self.index, name=label, fastpath=True) to tis_constructor_sliced = SparseSeries if isinstance(arr, ABCSparseArray) else self._constructor_sliced
result = tis_constructor_sliced(
values, index=self.index, name=label, fastpath=True) this basically takes that single check out of its wrapping function and:
does that makes more sense/feels safer? |
I open this suggestion as per @jorisvandenbossche's recommendation.
This issue follows in the steps of #18213 and #19850.
As it is commented in #18213,
_from_array
has a single difference with theSeries
constructor, how it handlesSparseArray
s:This process could be achieved in a similar way in
Series.__new__
; something on the lines of:What's the issue?
As @jorisvandenbossche pointed out, a change like this will result in a change of the API, as this:
will become this:
I'm not familiar with sparse data structures, but according to the docs all functionality is kept between
Series
andSparseSeries
. Furthermore, a simpleshould do it to go back to
Series
.Why change it, then?
Currently,
Series._from_array
is called only inside two functions:DataFrame._idx
andDataFrame. _box_col_values
. With the proposed change, those calls could be substituted by the default constructor.Being that the case, when working with
panda
's subclassing, one would be able to declare complex_constructor_slice
such as this:, which would allow for a more complex relationship between the subclassed
DataFrame
and its sliced version, including the transfer ofmetadata
according to the user's specification in__finalize__
.The text was updated successfully, but these errors were encountered: