{"action":"closed","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/25616","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/25616/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/25616/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/25616/events","html_url":"https://github.com/pandas-dev/pandas/issues/25616","id":419065010,"node_id":"MDU6SXNzdWU0MTkwNjUwMTA=","number":25616,"title":"pandas.DataFrame.replace seems taking number string as integer and run into overflow error","user":{"login":"heygrain","id":8529601,"node_id":"MDQ6VXNlcjg1Mjk2MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/8529601?v=4","gravatar_id":"","url":"https://api.github.com/users/heygrain","html_url":"https://github.com/heygrain","followers_url":"https://api.github.com/users/heygrain/followers","following_url":"https://api.github.com/users/heygrain/following{/other_user}","gists_url":"https://api.github.com/users/heygrain/gists{/gist_id}","starred_url":"https://api.github.com/users/heygrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heygrain/subscriptions","organizations_url":"https://api.github.com/users/heygrain/orgs","repos_url":"https://api.github.com/users/heygrain/repos","events_url":"https://api.github.com/users/heygrain/events{/privacy}","received_events_url":"https://api.github.com/users/heygrain/received_events","type":"User","site_admin":false},"labels":[{"id":76811,"node_id":"MDU6TGFiZWw3NjgxMQ==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Bug","name":"Bug","color":"e10c02","default":false},{"id":31404521,"node_id":"MDU6TGFiZWwzMTQwNDUyMQ==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Dtypes","name":"Dtypes","color":"e102d8","default":false},{"id":32815646,"node_id":"MDU6TGFiZWwzMjgxNTY0Ng==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Regression","name":"Regression","color":"e11d21","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/pandas-dev/pandas/milestones/64","html_url":"https://github.com/pandas-dev/pandas/milestone/64","labels_url":"https://api.github.com/repos/pandas-dev/pandas/milestones/64/labels","id":4129119,"node_id":"MDk6TWlsZXN0b25lNDEyOTExOQ==","number":64,"title":"0.24.3","description":"on-merge: backport to 0.24.x","creator":{"login":"jorisvandenbossche","id":1020496,"node_id":"MDQ6VXNlcjEwMjA0OTY=","avatar_url":"https://avatars2.githubusercontent.com/u/1020496?v=4","gravatar_id":"","url":"https://api.github.com/users/jorisvandenbossche","html_url":"https://github.com/jorisvandenbossche","followers_url":"https://api.github.com/users/jorisvandenbossche/followers","following_url":"https://api.github.com/users/jorisvandenbossche/following{/other_user}","gists_url":"https://api.github.com/users/jorisvandenbossche/gists{/gist_id}","starred_url":"https://api.github.com/users/jorisvandenbossche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jorisvandenbossche/subscriptions","organizations_url":"https://api.github.com/users/jorisvandenbossche/orgs","repos_url":"https://api.github.com/users/jorisvandenbossche/repos","events_url":"https://api.github.com/users/jorisvandenbossche/events{/privacy}","received_events_url":"https://api.github.com/users/jorisvandenbossche/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":1,"state":"open","created_at":"2019-03-11T13:56:56Z","updated_at":"2019-03-12T20:45:24Z","due_on":"2019-04-15T07:00:00Z","closed_at":null},"comments":6,"created_at":"2019-03-09T12:06:49Z","updated_at":"2019-03-12T20:45:24Z","closed_at":"2019-03-12T20:45:24Z","author_association":"NONE","body":"#### Code Sample\r\n\r\n```python\r\nimport pandas as pd\r\n\r\nx = {'user_id':['100000715097692381911', \r\n                '100003840837471130074'], \r\n     'item_id': [1, 2]\r\n     }\r\ndfx = pd.DataFrame(x)\r\ndfx['user_id'].replace(\r\n    {\r\n     '100000715097692381911': 0, \r\n     '100003840837471130074': 1\r\n     }, inplace=True)\r\n```\r\n#### Problem description\r\nI got overflow error:\r\n\r\nFile \"/home/grain/ml/lib/python3.6/site-packages/pandas/core/dtypes/cast.py\", line 683, in astype_nansafe\r\n    return lib.astype_intsafe(arr.ravel(), dtype).reshape(arr.shape)\r\n  File \"pandas/_libs/lib.pyx\", line 546, in pandas._libs.lib.astype_intsafe\r\nOverflowError: Python int too large to convert to C long\r\n\r\n*This error occurs on my laptop with pandas 0.24.1, python 3.6.7. The example code can handle the replacement correctly on another computer with an older version pandas 0.20.3.*\r\n\r\n#### Expected Output\r\n\r\nSince I loaded big id numbers like '100000715097692381911' as string type, the pandas.DataFrame.replace() method should replace it with the corresponding value in the dictionary. But I got overflow error. It seemed pandas took the id string as integer?\r\n\r\nAnd if I modify just the first element of 'user_id' column to 's100000715097692381911', then the code won't run into overflow.\r\n\r\n#### Output of ``pd.show_versions()``\r\n\r\n<details>\r\n\r\n[paste the output of ``pd.show_versions()`` here below this line]\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.6.7.final.0\r\npython-bits: 64\r\nOS: Linux\r\nOS-release: 4.15.0-46-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.24.1\r\npytest: None\r\npip: 19.0.3\r\nsetuptools: 40.6.3\r\nCython: None\r\nnumpy: 1.16.0\r\nscipy: 1.2.0\r\npyarrow: None\r\nxarray: None\r\nIPython: 7.2.0\r\nsphinx: None\r\npatsy: None\r\ndateutil: 2.7.5\r\npytz: 2018.3\r\nblosc: None\r\nbottleneck: None\r\ntables: None\r\nnumexpr: None\r\nfeather: None\r\nmatplotlib: 3.0.2\r\nopenpyxl: None\r\nxlrd: None\r\nxlwt: None\r\nxlsxwriter: None\r\nlxml.etree: None\r\nbs4: None\r\nhtml5lib: None\r\nsqlalchemy: None\r\npymysql: None\r\npsycopg2: None\r\njinja2: 2.10\r\ns3fs: None\r\nfastparquet: None\r\npandas_gbq: None\r\npandas_datareader: None\r\ngcsfs: None\r\n\r\n</details>\r\n"}}
{"actor":{"display_login":"jorisvandenbossche"}}