Skip to content

BUG: replace int64 dtype with bool coerces to int64 #9113

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

Closed
sinhrks opened this issue Dec 20, 2014 · 2 comments · Fixed by #29354
Closed

BUG: replace int64 dtype with bool coerces to int64 #9113

sinhrks opened this issue Dec 20, 2014 · 2 comments · Fixed by #29354
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented Dec 20, 2014

# NG
s = pd.Series([1, 2, 3])
s.replace(2, True)
#0    1
#1    1
#2    3
# dtype: int64

If target has object dtype, it works.

s = pd.Series(['x', 2, 3])
s.replace(2, True)
#0       x
#1    True
#2       3
# dtype: object
@jreback jreback added Bug Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions labels Dec 20, 2014
@jreback jreback added this to the 0.16.0 milestone Dec 20, 2014
@jreback
Copy link
Contributor

jreback commented Dec 20, 2014

This is numpy casting at work. If you can fix in a performant way, then ok.

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@mroeschke
Copy link
Member

Looks fixed on master. Could use a regression test.

In [26]: pd.__version__
Out[26]: '0.26.0.dev0+490.g9cfb8b55b'

In [27]: s = pd.Series([1, 2, 3])
    ...: s.replace(2, True)
Out[27]:
0       1
1    True
2       3
dtype: object

@mroeschke mroeschke added good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Bug Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions labels Oct 6, 2019
@pv8473h12 pv8473h12 mentioned this issue Nov 2, 2019
4 tasks
@jreback jreback modified the milestones: Contributions Welcome, 1.0 Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants