-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: ensuring that np.asarray() simple handles data as objects and doesn't… #22161
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
Codecov Report
@@ Coverage Diff @@
## master #22161 +/- ##
=======================================
Coverage 92.08% 92.08%
=======================================
Files 169 169
Lines 50704 50704
=======================================
Hits 46691 46691
Misses 4013 4013
Continue to review full report at Codecov.
|
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.
does this change anything from a user perspective?
@@ -134,7 +134,7 @@ def _ensure_data(values, dtype=None): | |||
return values, dtype, 'int64' | |||
|
|||
# we have failed, return object | |||
values = np.asarray(values) | |||
values = np.asarray(values, dtype=np.object) |
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.
so we actually should prob use pandas.core.dtypes.cast.construct_1d_array_preserving_na
which is even better here. further pls run the performance suite for things like factorize, value_counts, isin, this a very performance sensitive section.
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.
@jreback Actually, pandas.core.dtypes.cast.construct_1d_ndarray_preserving_na would not work for two reasons:
- For
[42, 's']
it returnsarray(['42', 's'], dtype='<U11')
and not the wantedarray([42, 's'], dtype=object))
, not sure this is the intended behavior of the function though - For
[np.nan]
it returnsarray([nan], dtype=float64)
which leads toresult[0] is np.nan
being False, but we would like to keep the id of the object.
Hello @realead! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on August 10, 2018 at 09:50 Hours UTC |
For asv continuous -f 1.1 upstream/master HEAD -b ^series_methods -b ^algorithms the result was:
|
can you rebase and run perf tests on algos. I find ever small changes sometimes can really impact perf here. |
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -573,6 +573,5 @@ Other | |||
- :meth: `~pandas.io.formats.style.Styler.background_gradient` now takes a ``text_color_threshold`` parameter to automatically lighten the text color based on the luminance of the background color. This improves readability with dark background colors without the need to limit the background colormap range. (:issue:`21258`) | |||
- Require at least 0.28.2 version of ``cython`` to support read-only memoryviews (:issue:`21688`) | |||
- :meth: `~pandas.io.formats.style.Styler.background_gradient` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` (:issue:`15204`) | |||
- | |||
- | |||
- :meth:`pandas.core.algorithms.isin` avoids spurious casting for lists (:issue:`22160`) |
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.
is this user visible?
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.
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 , this is an internal, routine, ok removing this whatsnew note.
…esn't try to do smart things (GH22160)
…s adjusting the test cases
There were no performance changes:
|
@realead ok with this, can you remove the whatsnew note. ping on green. |
Close/Open to trigger CI-run |
thanks @realead |
… try to do smart things (GH22160)
git diff upstream/master -u -- "*.py" | flake8 --diff