Skip to content

BUG: replace of numeric by string / dtype coversion #15743

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
jreback opened this issue Mar 20, 2017 · 2 comments
Closed

BUG: replace of numeric by string / dtype coversion #15743

jreback opened this issue Mar 20, 2017 · 2 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Mar 20, 2017

xref #12747

This was an item not closed by #12780 (but listed in #12747)

In [2]: pd.Series([1,2,3]).replace('1', np.nan)
Out[2]: 
0    NaN
1    2.0
2    3.0
dtype: float64
@ucals
Copy link

ucals commented Mar 24, 2017

Output should be:

0    1.0
1    NaN
2    3.0
dtype: float64

right? I'd like to try this one

@jreback
Copy link
Contributor Author

jreback commented Mar 24, 2017

The result should be the same as this. IOW the string '1' is NOT found in the original dataset (its a numeric 1). So should return unchanged. Step thru the code and you will see the modification happening, this is numpy behavior, but its not normal / natural in the real world :>

In [2]: pd.Series([1,2,3]).replace('10', np.nan)
Out[2]: 
0    1
1    2
2    3
dtype: int64

@jreback jreback modified the milestones: 0.20.0, Next Major Release Mar 27, 2017
mattip pushed a commit to mattip/pandas that referenced this issue Apr 3, 2017
closes pandas-dev#15743

Author: Carlos Souza <[email protected]>
Author: Jeff Reback <[email protected]>

Closes pandas-dev#15812 from ucals/bug-fix-15743 and squashes the following commits:

e6e4971 [Carlos Souza] Adding replace unicode with number and replace mixed types with string tests
bd31b2b [Carlos Souza] Resolving merge conflict by incorporating @jreback suggestions
73805ce [Jeff Reback] CLN: add infer_dtype_from_array
45e67e4 [Carlos Souza] Fixing PEP8 line indent
0a98557 [Carlos Souza] BUG: replace of numeric by string fixed
97e1f18 [Carlos Souza] Test
e62763c [Carlos Souza] Fixing PEP8 line indent
080c71e [Carlos Souza] BUG: replace of numeric by string fixed
8b463cb [Carlos Souza] Merge remote-tracking branch 'upstream/master'
9fc617b [Carlos Souza] Merge remote-tracking branch 'upstream/master'
e12bca7 [Carlos Souza] Sync fork
676a4e5 [Carlos Souza] Test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants