-
-
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
DEPR: Warn on empty Series dtype inference #20802
Conversation
FutureWarning from float to object
FYI, d80e1c7 has the changes. Everything else is catching / fixing warning internal to pandas. This ended up being a decent-sized change. |
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.
generally looks good. looks like you have some extra commits (so rebase on master), and a couple of style changes.
@@ -862,6 +862,7 @@ Other API Changes | |||
Deprecations | |||
~~~~~~~~~~~~ | |||
|
|||
- The inferred dtype for an empty Series will change from ``float`` to ``object`` (:issue:`17261`). |
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.
double-backticks on Series
@@ -954,7 +954,11 @@ def _map_values(self, mapper, na_action=None): | |||
# we specify the keys here to handle the | |||
# possibility that they are tuples | |||
from pandas import Series | |||
mapper = Series(mapper) | |||
if len(mapper) == 0: |
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 think this might be worthwhile to make a function in pandas.core.dtypes.cast.maybe_infer_1d_array_dtype
@@ -5399,7 +5399,11 @@ def fillna(self, value=None, method=None, axis=None, inplace=False, | |||
if self.ndim == 1: | |||
if isinstance(value, (dict, ABCSeries)): | |||
from pandas import Series | |||
value = Series(value) | |||
if len(value) == 0: | |||
series_dtype = 'float' |
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.
see above
name(s) to set | ||
level : int, level name, or sequence of int/level names (default None) | ||
If the index is a MultiIndex (hierarchical), level(s) to set (None | ||
for all levels). Otherwise level must be None |
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.
looks like you have some extra commits?
@@ -388,10 +388,14 @@ def test_map(self): | |||
|
|||
@pytest.mark.parametrize("index", tm.all_index_generator(10)) | |||
def test_map_empty(self, index): | |||
s = Series(index) | |||
if len(index) == 0: |
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.
use function as above
Sorry about the empty commits, will fix that up. Still going through and squashing warnings. There are a few cases internally where we construct an empty series. e.g. In [1]: import pandas as pd
In [2]: pd.Series([], dtype='object').groupby([]).apply(lambda x: 1)
Out[2]: Series([], dtype: float64) How should we handle that?
The problem w/ 2 is that there's nothing the user can do to silence the warning. |
@TomAugspurger can you close or update |
@jreback @jorisvandenbossche do you think we want to change this before 1.0? |
@TomAugspurger can you merge master |
There's a decent amount of work to do here to avoid the warnings
internally. Will try to make time.
…On Sun, Nov 18, 2018 at 4:07 PM Jeff Reback ***@***.***> wrote:
@TomAugspurger <https://github.com/TomAugspurger> can you merge master
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20802 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIlxE1_nFXT33ZyVrGy5GKVNKLTv7ks5uwdopgaJpZM4Tgluf>
.
|
@TomAugspurger keep this one open? |
Probably not :/ I suppose we can just live with this. A little artifact of the time Series used to be an ndarray. |
We're changing
Series([])
to beobject
instead offloat
. This does the warninggit diff upstream/master -u -- "*.py" | flake8 --diff