{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/19998","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19998/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19998/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19998/events","html_url":"https://github.com/pandas-dev/pandas/issues/19998","id":302403736,"number":19998,"title":"Series replace, unexpected fill behavior","user":{"login":"rasmuse","id":1210973,"avatar_url":"https://avatars2.githubusercontent.com/u/1210973?v=4","gravatar_id":"","url":"https://api.github.com/users/rasmuse","html_url":"https://github.com/rasmuse","followers_url":"https://api.github.com/users/rasmuse/followers","following_url":"https://api.github.com/users/rasmuse/following{/other_user}","gists_url":"https://api.github.com/users/rasmuse/gists{/gist_id}","starred_url":"https://api.github.com/users/rasmuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rasmuse/subscriptions","organizations_url":"https://api.github.com/users/rasmuse/orgs","repos_url":"https://api.github.com/users/rasmuse/repos","events_url":"https://api.github.com/users/rasmuse/events{/privacy}","received_events_url":"https://api.github.com/users/rasmuse/received_events","type":"User","site_admin":false},"labels":[{"id":34444536,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Usage%20Question","name":"Usage Question","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-05T18:07:00Z","updated_at":"2018-03-08T17:16:18Z","closed_at":null,"author_association":"NONE","body":"Many thanks for the excellent software. This report is about behavior I did not expect. Not sure if it is a bug or not.\r\n\r\n```python\r\n>>> import pandas as pd\r\n>>> s = pd.Series([10, 20, 30, 'a', 'a', 'b', 'a'])\r\n>>> print(s)\r\n0    10\r\n1    20\r\n2    30\r\n3     a\r\n4     a\r\n5     b\r\n6     a\r\ndtype: object\r\n>>> print(s.replace('a', None))\r\n0    10\r\n1    20\r\n2    30\r\n3    30\r\n4    30\r\n5     b\r\n6     b\r\ndtype: object\r\n>>> print(s.replace({'a': None}))\r\n0      10\r\n1      20\r\n2      30\r\n3    None\r\n4    None\r\n5       b\r\n6    None\r\ndtype: object\r\n```\r\n#### Problem description\r\n\r\nThis behavior was unexpected for me. I would have assumed that these two lines would produce the same output:\r\n```python\r\ns.replace('a', None)\r\ns.replace({'a': None})\r\n```\r\n\r\nIn my particular use case, I was actually looking to just replace `'a'`with `None` and therefore did `s.replace('a', None)`. I did not check output carefully and therefore ended up with some very strange behavior down the line in my data analysis.\r\n\r\nNot sure if this is to be considered a bug or not. Docs are not entirely clear on what is intended behavior. Possible solutions could include\r\n\r\n* Describe behavior in docs (the filling behavior is barely described at all).\r\n* Hint that something like `s.replace('a', numpy.nan)` might be a better option.\r\n* Change API to require a more explicit opt-in for filling.\r\n\r\n#### Output of ``pd.show_versions()``\r\n\r\n<details>\r\n\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.6.4.final.0\r\npython-bits: 64\r\nOS: Linux\r\nOS-release: 4.4.0-116-generic\r\nmachine: x86_64\r\nprocessor: x86_64\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en_US.UTF-8\r\nLOCALE: en_US.UTF-8\r\n\r\npandas: 0.22.0\r\npytest: None\r\npip: 9.0.1\r\nsetuptools: 38.5.1\r\nCython: None\r\nnumpy: 1.14.0\r\nscipy: None\r\npyarrow: None\r\nxarray: None\r\nIPython: None\r\nsphinx: None\r\npatsy: None\r\ndateutil: 2.6.1\r\npytz: 2018.3\r\nblosc: None\r\nbottleneck: None\r\ntables: None\r\nnumexpr: None\r\nfeather: None\r\nmatplotlib: None\r\nopenpyxl: None\r\nxlrd: None\r\nxlwt: None\r\nxlsxwriter: None\r\nlxml: None\r\nbs4: None\r\nhtml5lib: None\r\nsqlalchemy: None\r\npymysql: None\r\npsycopg2: None\r\njinja2: None\r\ns3fs: None\r\nfastparquet: None\r\npandas_gbq: None\r\npandas_datareader: None\r\n\r\n</details>\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/371556795","html_url":"https://github.com/pandas-dev/pandas/issues/19998#issuecomment-371556795","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19998","id":371556795,"user":{"login":"gfyoung","id":9273653,"avatar_url":"https://avatars0.githubusercontent.com/u/9273653?v=4","gravatar_id":"","url":"https://api.github.com/users/gfyoung","html_url":"https://github.com/gfyoung","followers_url":"https://api.github.com/users/gfyoung/followers","following_url":"https://api.github.com/users/gfyoung/following{/other_user}","gists_url":"https://api.github.com/users/gfyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/gfyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfyoung/subscriptions","organizations_url":"https://api.github.com/users/gfyoung/orgs","repos_url":"https://api.github.com/users/gfyoung/repos","events_url":"https://api.github.com/users/gfyoung/events{/privacy}","received_events_url":"https://api.github.com/users/gfyoung/received_events","type":"User","site_admin":false},"created_at":"2018-03-08T17:16:18Z","updated_at":"2018-03-08T17:16:18Z","author_association":"MEMBER","body":"@reidy-p : Excellent explanation!"}}
{"actor":{"display_login":"gfyoung"}}