{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/19123","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19123/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19123/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19123/events","html_url":"https://github.com/pandas-dev/pandas/issues/19123","id":286591864,"node_id":"MDU6SXNzdWUyODY1OTE4NjQ=","number":19123,"title":"DatetimeIndex + ndarray[int] wrong, reverse op errors","user":{"login":"jbrockmendel","id":8078968,"node_id":"MDQ6VXNlcjgwNzg5Njg=","avatar_url":"https://avatars1.githubusercontent.com/u/8078968?v=4","gravatar_id":"","url":"https://api.github.com/users/jbrockmendel","html_url":"https://github.com/jbrockmendel","followers_url":"https://api.github.com/users/jbrockmendel/followers","following_url":"https://api.github.com/users/jbrockmendel/following{/other_user}","gists_url":"https://api.github.com/users/jbrockmendel/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrockmendel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrockmendel/subscriptions","organizations_url":"https://api.github.com/users/jbrockmendel/orgs","repos_url":"https://api.github.com/users/jbrockmendel/repos","events_url":"https://api.github.com/users/jbrockmendel/events{/privacy}","received_events_url":"https://api.github.com/users/jbrockmendel/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":211840,"node_id":"MDU6TGFiZWwyMTE4NDA=","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Timeseries","name":"Timeseries","color":"AFEEEE","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/pandas-dev/pandas/milestones/55","html_url":"https://github.com/pandas-dev/pandas/milestone/55","labels_url":"https://api.github.com/repos/pandas-dev/pandas/milestones/55/labels","id":3228419,"node_id":"MDk6TWlsZXN0b25lMzIyODQxOQ==","number":55,"title":"0.24.0","description":"","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":84,"closed_issues":264,"state":"open","created_at":"2018-03-29T12:00:12Z","updated_at":"2018-07-11T00:14:39Z","due_on":"2018-08-31T07:00:00Z","closed_at":null},"comments":3,"created_at":"2018-01-07T19:18:03Z","updated_at":"2018-07-11T15:23:01Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"In both 0.22.0 and 1265f66860a1a\r\n```\r\ndti = pd.date_range('2016-01-01', periods=3, freq='D')\r\ntdi = pd.TimedeltaIndex(['1 day', '2days', '3 days'], freq='D')\r\narr = np.array([1, 2, 3], dtype=np.int64)\r\n\r\n>>> dti + arr\r\nDatetimeIndex(['2016-01-01', '2016-01-02', '2016-01-03'], dtype='datetime64[ns]', freq='86400000000001N')\r\n\r\n>>> dti - arr\r\nDatetimeIndex(['2015-12-31 23:59:59.999999999',\r\n               '2016-01-01 23:59:59.999999998',\r\n               '2016-01-02 23:59:59.999999997'],\r\n              dtype='datetime64[ns]', freq='86399999999999N')\r\n\r\n>>> arr + dti\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\nTypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'DatetimeIndex'\r\n\r\n>>> tdi + arr\r\nTimedeltaIndex(['1 days 00:00:00.000000', '2 days 00:00:00.000000',\r\n                '3 days 00:00:00.000000'],\r\n               dtype='timedelta64[ns]', freq='86400000000001N')\r\n\r\n>>> arr + tdi\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\nTypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'TimedeltaIndex'\r\n\r\n>>> tdi - arr\r\nTimedeltaIndex(['0 days 23:59:59.999999', '1 days 23:59:59.999999',\r\n                '2 days 23:59:59.999999'],\r\n               dtype='timedelta64[ns]', freq='86399999999999N')\r\n\r\n>>> arr - tdi\r\nTimedeltaIndex(['-1 days +00:00:00.000000', '-2 days +00:00:00.000000',\r\n                '-3 days +00:00:00.000000'],\r\n               dtype='timedelta64[ns]', freq='-86399999999999N')\r\n```\r\n\r\nExpected:\r\n```\r\ndti = pd.date_range('2016-01-01', periods=3, freq='D')\r\ntdi = pd.TimedeltaIndex(['1 day', '2days', '3 days'], freq='D')\r\narr = np.array([1, 2, 3], dtype=np.int64)\r\n\r\n>>> dti + arr\r\nDatetimeIndex(['2016-01-02', '2016-01-04', '2016-01-06'], dtype='datetime64[ns]', freq='2D')\r\n\r\n>>> arr + dti\r\nDatetimeIndex(['2016-01-02', '2016-01-04', '2016-01-06'], dtype='datetime64[ns]', freq='2D')\r\n\r\n>>> tdi + arr\r\nTimedeltaIndex(['2 days', '4 days', '6 days'], dtype='timedelta64[ns]', freq='2D')\r\n\r\n>>> arr + tdi\r\nTimedeltaIndex(['2 days', '4 days', '6 days'], dtype='timedelta64[ns]', freq='2D')\r\n\r\n>>> tdi - arr\r\nTimedeltaIndex(['0 days', '0 days', '0 days'], dtype='timedelta64[ns]', freq=None)\r\n\r\n>>> arr - tdi\r\nTimedeltaIndex(['0 days', '0 days', '0 days'], dtype='timedelta64[ns]', freq=None)\r\n```"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/404209643","html_url":"https://github.com/pandas-dev/pandas/issues/19123#issuecomment-404209643","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19123","id":404209643,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDIwOTY0Mw==","user":{"login":"jbrockmendel","id":8078968,"node_id":"MDQ6VXNlcjgwNzg5Njg=","avatar_url":"https://avatars1.githubusercontent.com/u/8078968?v=4","gravatar_id":"","url":"https://api.github.com/users/jbrockmendel","html_url":"https://github.com/jbrockmendel","followers_url":"https://api.github.com/users/jbrockmendel/followers","following_url":"https://api.github.com/users/jbrockmendel/following{/other_user}","gists_url":"https://api.github.com/users/jbrockmendel/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrockmendel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrockmendel/subscriptions","organizations_url":"https://api.github.com/users/jbrockmendel/orgs","repos_url":"https://api.github.com/users/jbrockmendel/repos","events_url":"https://api.github.com/users/jbrockmendel/events{/privacy}","received_events_url":"https://api.github.com/users/jbrockmendel/received_events","type":"User","site_admin":false},"created_at":"2018-07-11T15:23:01Z","updated_at":"2018-07-11T15:23:01Z","author_association":"CONTRIBUTOR","body":"Hmm this also leads to a weird non-commutativity:\r\n\r\n```\r\ndti = pd.date_range('2016-01-01', periods=3, freq='D')\r\narr = np.array([1, 2, 3], dtype=np.int64)\r\n\r\n>>> dti + arr\r\nDatetimeIndex(['2016-01-02', '2016-01-04', '2016-01-06'], dtype='datetime64[ns]', freq='2D')\r\n>>> (dti + arr) - arr\r\nDatetimeIndex(['2015-12-31', '2015-12-31', '2015-12-31'], dtype='datetime64[ns]', freq=None)\r\n```\r\n\r\nSince `dti+arr` comes back with freq=2D, the subtraction operation doens't just undo the addition."}}
{"actor":{"display_login":"jbrockmendel"}}