-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
CLN: Remove Series._from_array #19893
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
Conversation
Transfer its check to DataFrame._box_col_values
until is properly deleted
Codecov Report
@@ Coverage Diff @@
## master #19893 +/- ##
==========================================
+ Coverage 91.65% 91.66% +<.01%
==========================================
Files 150 150
Lines 48915 48939 +24
==========================================
+ Hits 44835 44859 +24
Misses 4080 4080
Continue to review full report at Codecov.
|
|
Hello @jaumebonet! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on February 26, 2018 at 14:55 Hours UTC |
pandas/tests/frame/test_subclass.py
Outdated
| assert not isinstance(result, tm.SubclassedDataFrame) | ||
| tm.assert_series_equal(result, expected) | ||
|
|
||
| def test_frame_subclassing_and_inherit(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of these tests? this is another issue, yes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be in a new PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote it to check that that approach would work now. I'll take it out.
pandas/core/frame.py
Outdated
| # This check here was previously performed in Series._from_array | ||
| # By doing it here there is no need for that function anymore | ||
| # GH#19883. | ||
| from pandas.core.dtypes.generic import ABCSparseArray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this a function like _get_series_result_type and put it near _get_frame_result_type in pandas/core/dtypes/concat.py, it should just take self and return the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the idea.
Wouldn't it make more sense to be in pandas/core/dtypes/commons.py ? As that file is already imported to frame.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, common is for introspection, not conversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!
pandas/core/frame.py
Outdated
| """ provide boxed values for a column """ | ||
| return self._constructor_sliced._from_array(values, index=self.index, | ||
| name=items, fastpath=True) | ||
| # This check here was previously performed in Series._from_array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove all of this commentary
to check type of DataFrame._constructor_sliced
|
|
||
|
|
||
| def _get_sliced_frame_result_type(data, obj): | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a full doc-string
pandas/core/dtypes/concat.py
Outdated
| if is_sparse(data): | ||
| from pandas.core.sparse.api import SparseSeries | ||
| return SparseSeries | ||
| else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just return, no else needed
| the data is sparse or not. | ||
| """ | ||
| if is_sparse(data): | ||
| from pandas.core.sparse.api import SparseSeries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from pandas import
pandas/core/frame.py
Outdated
| """ provide boxed values for a column """ | ||
| return self._constructor_sliced._from_array(values, index=self.index, | ||
| name=items, fastpath=True) | ||
| from pandas.core.dtypes.concat import _get_sliced_frame_result_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be imported at the top
pandas/core/frame.py
Outdated
| return self._constructor_sliced._from_array(values, index=self.index, | ||
| name=items, fastpath=True) | ||
| from pandas.core.dtypes.concat import _get_sliced_frame_result_type | ||
| this_constructor_sliced = _get_sliced_frame_result_type(values, self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this klass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small changes, ping on green
pandas/core/dtypes/concat.py
Outdated
| Parameters | ||
| ---------- | ||
| data : ndarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array-like
| Series or SparseSeries | ||
| """ | ||
| if is_sparse(data): | ||
| from pandas.core.sparse.api import SparseSeries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from pandas import SparseSeries
|
done! |
|
thanks ping on green. |
|
sorry... I'm not sure what "ping on green" means in this context 😅 |
|
it means watch this page and report when all of the checks are green. |
|
thanks @jaumebonet |
This PR transfers the class check of
Series._from_arraytoDataFrame._box_col_values; removing the need for calling theSeries._from_arrayand allowing for user-defined slice-inheritance of metadata.I opted to delete the function as it was private but leave the
Series.from_arraypublic access working and it's FutureWarning of deprecation, as it was. To do that, I had to modifySeries.from_arrayso it would keep also its original functionality until is completely deleted.git diff upstream/master -u -- "*.py" | flake8 --diff