{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/21194","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21194/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21194/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21194/events","html_url":"https://github.com/pandas-dev/pandas/issues/21194","id":326214092,"number":21194,"title":"DataFrame.asof() : Timezone Awareness / Naivety comparison TypeError (incorrect)","user":{"login":"emmet02","id":10803258,"avatar_url":"https://avatars3.githubusercontent.com/u/10803258?v=4","gravatar_id":"","url":"https://api.github.com/users/emmet02","html_url":"https://github.com/emmet02","followers_url":"https://api.github.com/users/emmet02/followers","following_url":"https://api.github.com/users/emmet02/following{/other_user}","gists_url":"https://api.github.com/users/emmet02/gists{/gist_id}","starred_url":"https://api.github.com/users/emmet02/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emmet02/subscriptions","organizations_url":"https://api.github.com/users/emmet02/orgs","repos_url":"https://api.github.com/users/emmet02/repos","events_url":"https://api.github.com/users/emmet02/events{/privacy}","received_events_url":"https://api.github.com/users/emmet02/received_events","type":"User","site_admin":false},"labels":[{"id":195647922,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Difficulty%20Intermediate","name":"Difficulty Intermediate","color":"fbca04","default":false},{"id":31404521,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Dtypes","name":"Dtypes","color":"e102d8","default":false},{"id":195648009,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Effort%20Low","name":"Effort Low","color":"006b75","default":false},{"id":2822098,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Indexing","name":"Indexing","color":"0b02e1","default":false},{"id":211840,"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/56","html_url":"https://github.com/pandas-dev/pandas/milestone/56","labels_url":"https://api.github.com/repos/pandas-dev/pandas/milestones/56/labels","id":3267242,"number":56,"title":"0.23.1","description":"","creator":{"login":"jreback","id":953992,"avatar_url":"https://avatars2.githubusercontent.com/u/953992?v=4","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"open_issues":48,"closed_issues":46,"state":"open","created_at":"2018-04-14T14:52:46Z","updated_at":"2018-05-29T10:41:28Z","due_on":"2018-06-08T07:00:00Z","closed_at":null},"comments":2,"created_at":"2018-05-24T17:13:48Z","updated_at":"2018-05-29T15:12:49Z","closed_at":null,"author_association":"NONE","body":"```\r\nimport pandas as pd\r\n\r\n# Create some random Timestamps\r\ntimestamp1 = pd.Timestamp('2018-01-01 21:00:05.001+00:00')\r\ntimestamp2 = pd.Timestamp('2018-01-01 22:35:10.550+00:00')\r\n\r\n# Get an internal timestamp, so asof should give us the lesser value\r\ntimestamp_internal = timestamp2 + ((timestamp2 - timestamp1) / 2)\r\n\r\n# Create a DataFrame\r\ndf = pd.DataFrame(data=[1,2], index=[timestamp1, timestamp2])\r\n\r\n# display it\r\ndf\r\n                                  0\r\n2018-01-01 21:00:05.001000+00:00  1\r\n2018-01-01 22:35:10.550000+00:00  2\r\n\r\n# Now call asof() and show the issue\r\ndf.asof(timestamp_internal)\r\nTraceback (most recent call last):\r\n  File \"<input>\", line 1, in <module>\r\n  File \"C:\\Anaconda3\\envs\\py36\\lib\\site-packages\\pandas\\core\\generic.py\", line 6144, in asof\r\n    locs = self.index.asof_locs(where, ~(nulls.values))\r\n  File \"C:\\Anaconda3\\envs\\py36\\lib\\site-packages\\pandas\\core\\indexes\\base.py\", line 2489, in asof_locs\r\n    result[(locs == 0) & (where < self.values[first])] = -1\r\n  File \"C:\\Anaconda3\\envs\\py36\\lib\\site-packages\\pandas\\core\\indexes\\datetimes.py\", line 136, in wrapper\r\n    self._assert_tzawareness_compat(other)\r\n  File \"C:\\Anaconda3\\envs\\py36\\lib\\site-packages\\pandas\\core\\indexes\\datetimes.py\", line 672, in _assert_tzawareness_compat\r\n    raise TypeError('Cannot compare tz-naive and tz-aware '\r\nTypeError: Cannot compare tz-naive and tz-aware datetime-like objects\r\n\r\n# Demonstrate other errant behavior - Try using a tz-naive Timestamp to lookup the frame\r\ndf.asof(timestamp_innie.tz_localize(None))\r\nTraceback (most recent call last):\r\n  File \"<input>\", line 1, in <module>\r\n  File \"C:\\Anaconda3\\envs\\py36\\lib\\site-packages\\pandas\\core\\generic.py\", line 6108, in asof\r\n    if where < start:\r\n  File \"pandas\\_libs\\tslibs\\timestamps.pyx\", line 164, in pandas._libs.tslibs.timestamps._Timestamp.__richcmp__\r\n  File \"pandas\\_libs\\tslibs\\timestamps.pyx\", line 224, in pandas._libs.tslibs.timestamps._Timestamp._assert_tzawareness_compat\r\nTypeError: Cannot compare tz-naive and tz-aware timestamps\r\n```\r\n#### Problem description\r\nSomehow the DataFrame index is losing the 'awareness' of the timezone of the original Timestamps. \r\nThis has only been noticed recently, following a recent upgrade to the newest version of pandas, however I cannot say for sure whether or not it has been a very recent change to pandas which has caused this.\r\n\r\nI am confident (_though not **100%** certain_) that the expected usage worked previously (_nor am in a position to test right now_).\r\n\r\n**EDIT:** Have tested this with pandas=0.22.0 and the expected output is now working fine.\r\n\r\nHopefully the bug is reproducible.\r\n\r\n#### Expected Output\r\n0    1\r\nName: 2018-01-01 23:22:43.324500+0000, dtype: int64\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\n\r\npd.show_versions()\r\nMatplotlib support failed\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.6.5.final.0\r\npython-bits: 64\r\nOS: Windows\r\nOS-release: 10\r\nmachine: AMD64\r\nprocessor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: None\r\nLOCALE: None.None\r\npandas: 0.23.0\r\npytest: None\r\npip: 10.0.1\r\nsetuptools: 39.1.0\r\nCython: 0.28.2\r\nnumpy: 1.13.3\r\nscipy: 1.1.0\r\npyarrow: 0.7.0\r\nxarray: 0.10.4\r\nIPython: 6.4.0\r\nsphinx: 1.7.4\r\npatsy: 0.5.0\r\ndateutil: 2.7.3\r\npytz: 2018.4\r\nblosc: None\r\nbottleneck: None\r\ntables: 3.4.3\r\nnumexpr: 2.6.5\r\nfeather: 0.4.0\r\nmatplotlib: 2.2.2\r\nopenpyxl: 2.5.3\r\nxlrd: 1.1.0\r\nxlwt: None\r\nxlsxwriter: 1.0.4\r\nlxml: 4.2.1\r\nbs4: 4.6.0\r\nhtml5lib: 0.9999999\r\nsqlalchemy: 1.2.7\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\n\r\n</details>\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/392814137","html_url":"https://github.com/pandas-dev/pandas/issues/21194#issuecomment-392814137","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21194","id":392814137,"user":{"login":"TomAugspurger","id":1312546,"avatar_url":"https://avatars3.githubusercontent.com/u/1312546?v=4","gravatar_id":"","url":"https://api.github.com/users/TomAugspurger","html_url":"https://github.com/TomAugspurger","followers_url":"https://api.github.com/users/TomAugspurger/followers","following_url":"https://api.github.com/users/TomAugspurger/following{/other_user}","gists_url":"https://api.github.com/users/TomAugspurger/gists{/gist_id}","starred_url":"https://api.github.com/users/TomAugspurger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomAugspurger/subscriptions","organizations_url":"https://api.github.com/users/TomAugspurger/orgs","repos_url":"https://api.github.com/users/TomAugspurger/repos","events_url":"https://api.github.com/users/TomAugspurger/events{/privacy}","received_events_url":"https://api.github.com/users/TomAugspurger/received_events","type":"User","site_admin":false},"created_at":"2018-05-29T15:12:49Z","updated_at":"2018-05-29T15:12:49Z","author_association":"CONTRIBUTOR","body":"That would be great. Let us know if you have any issues getting started.\n\nOn Tue, May 29, 2018 at 7:41 AM, Marlene Silva Marchena <\nnotifications@github.com> wrote:\n\n> @TomAugspurger <https://github.com/TomAugspurger> I have checked your\n> solution and it actually solve the problem. If you need some help I can\n> make the correction and implement the test.\n>\n> —\n> You are receiving this because you were mentioned.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/pandas-dev/pandas/issues/21194#issuecomment-392801679>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ABQHIgxZGpxUKyMP2LT5NlThM67HAoqdks5t3V4OgaJpZM4UMpnE>\n> .\n>\n"}}
{"actor":{"display_login":"TomAugspurger"}}