{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/22642","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/22642/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/22642/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/22642/events","html_url":"https://github.com/pandas-dev/pandas/issues/22642","id":358334688,"node_id":"MDU6SXNzdWUzNTgzMzQ2ODg=","number":22642,"title":"BUG: df.sum() of string columns depends on whether or not they can be coerced to numbers","user":{"login":"rosnfeld","id":5356340,"node_id":"MDQ6VXNlcjUzNTYzNDA=","avatar_url":"https://avatars1.githubusercontent.com/u/5356340?v=4","gravatar_id":"","url":"https://api.github.com/users/rosnfeld","html_url":"https://github.com/rosnfeld","followers_url":"https://api.github.com/users/rosnfeld/followers","following_url":"https://api.github.com/users/rosnfeld/following{/other_user}","gists_url":"https://api.github.com/users/rosnfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/rosnfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosnfeld/subscriptions","organizations_url":"https://api.github.com/users/rosnfeld/orgs","repos_url":"https://api.github.com/users/rosnfeld/repos","events_url":"https://api.github.com/users/rosnfeld/events{/privacy}","received_events_url":"https://api.github.com/users/rosnfeld/received_events","type":"User","site_admin":false},"labels":[{"id":57296398,"node_id":"MDU6TGFiZWw1NzI5NjM5OA==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Algos","name":"Algos","color":"eb6420","default":false},{"id":219960758,"node_id":"MDU6TGFiZWwyMTk5NjA3NTg=","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Needs%20Discussion","name":"Needs Discussion","color":"207de5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-08T23:13:00Z","updated_at":"2018-09-14T18:38:11Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Note that all the columns in this example are string columns:\r\n\r\n```python\r\nIn [32]: df1 = pd.DataFrame(data={'a':['1', '2'], 'b':['3', '4']})\r\n\r\nIn [33]: df1.sum(axis=1)\r\nOut[33]: \r\n0    13.0\r\n1    24.0\r\ndtype: float64\r\n\r\nIn [34]: df2 = pd.DataFrame(data={'a':['i', 'j'], 'b':['m', 'n']})\r\n\r\nIn [35]: df2.sum(axis=1)\r\nOut[35]: \r\n0    im\r\n1    jn\r\ndtype: object\r\n```\r\n#### Problem description\r\n\r\nIt would seem a bug, or at least very surprising behavior, that the sum() operation would depend on the _contents_ of the strings when summing the columns.\r\n\r\nNot sure if this has been reported before - I wasn't sure exactly what to search on, but wasn't able to find anything.\r\n\r\n#### Expected Output\r\nI would expect the columns to be concatenated as strings and then left as strings, just the same as if we did `df1.a + df1.b`.\r\n```python\r\nIn [25]: df1.a + df1.b\r\nOut[25]: \r\n0    13\r\n1    24\r\ndtype: object\r\n\r\n```\r\n\r\n#### Output of ``pd.show_versions()``\r\nOn current master as of this filing.\r\n\r\n<details>\r\nIn [26]: pd.show_versions()\r\nNo module named 'dask'\r\n\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: 996f361f8e6986ea1c65ccb164a4c585e1f4a027\r\npython: 3.6.6.final.0\r\npython-bits: 64\r\nOS: Linux\r\nOS-release: 4.4.0-128-generic\r\nmachine: x86_64\r\nprocessor: x86_64\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en_GB.UTF-8\r\nLOCALE: en_GB.UTF-8\r\n\r\npandas: 0.24.0.dev0+562.g996f361\r\npytest: 3.7.4\r\npip: 10.0.1\r\nsetuptools: 40.2.0\r\nCython: 0.28.5\r\nnumpy: 1.15.1\r\nscipy: 1.1.0\r\npyarrow: 0.9.0\r\nxarray: 0.10.8\r\nIPython: 6.5.0\r\nsphinx: 1.7.8\r\npatsy: 0.5.0\r\ndateutil: 2.7.3\r\npytz: 2018.5\r\nblosc: None\r\nbottleneck: 1.2.1\r\ntables: 3.4.4\r\nnumexpr: 2.6.8\r\nfeather: 0.4.0\r\nmatplotlib: 2.2.3\r\nopenpyxl: 2.5.6\r\nxlrd: 1.1.0\r\nxlwt: 1.3.0\r\nxlsxwriter: 1.1.0\r\nlxml: 4.2.4\r\nbs4: 4.6.3\r\nhtml5lib: 1.0.1\r\nsqlalchemy: 1.2.11\r\npymysql: 0.9.2\r\npsycopg2: None\r\njinja2: 2.10\r\ns3fs: 0.1.6\r\nfastparquet: 0.1.6\r\npandas_gbq: None\r\npandas_datareader: None\r\ngcsfs: 0.1.2\r\n</details>\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/421448166","html_url":"https://github.com/pandas-dev/pandas/issues/22642#issuecomment-421448166","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/22642","id":421448166,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTQ0ODE2Ng==","user":{"login":"apnewberry","id":31109952,"node_id":"MDQ6VXNlcjMxMTA5OTUy","avatar_url":"https://avatars1.githubusercontent.com/u/31109952?v=4","gravatar_id":"","url":"https://api.github.com/users/apnewberry","html_url":"https://github.com/apnewberry","followers_url":"https://api.github.com/users/apnewberry/followers","following_url":"https://api.github.com/users/apnewberry/following{/other_user}","gists_url":"https://api.github.com/users/apnewberry/gists{/gist_id}","starred_url":"https://api.github.com/users/apnewberry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apnewberry/subscriptions","organizations_url":"https://api.github.com/users/apnewberry/orgs","repos_url":"https://api.github.com/users/apnewberry/repos","events_url":"https://api.github.com/users/apnewberry/events{/privacy}","received_events_url":"https://api.github.com/users/apnewberry/received_events","type":"User","site_admin":false},"created_at":"2018-09-14T18:38:11Z","updated_at":"2018-09-14T18:38:11Z","author_association":"NONE","body":"On pandas 0.23.4 I'm seeing a different behavior: the resulting dtype is int64, rather than float64. Given the `astype(int)` my expectation would be that the resulting dtype is an int rather than a float. Is there automatic conversion going on here that I'm missing?\r\n\r\n```python\r\nIn [8]: pd.__version__\r\nOut[8]: '0.23.4'\r\n\r\nIn [9]: df1 = pd.DataFrame(data={'a':['1', '2'], 'b':['3', '4']})\r\n\r\nIn [10]: df1.astype(int).sum(axis=1)\r\nOut[10]: \r\n0    4\r\n1    6\r\ndtype: int64\r\n```"}}
{"actor":{"display_login":"apnewberry"}}