{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/12018","labels_url":"https://api.github.com/repos/pydata/pandas/issues/12018/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/12018/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/12018/events","html_url":"https://github.com/pydata/pandas/issues/12018","id":126053084,"number":12018,"title":"`df.to_csv` on python3 throws `TypeError: a bytes-like object is required, not 'str'`","user":{"login":"arokem","id":118582,"avatar_url":"https://avatars.githubusercontent.com/u/118582?v=3","gravatar_id":"","url":"https://api.github.com/users/arokem","html_url":"https://github.com/arokem","followers_url":"https://api.github.com/users/arokem/followers","following_url":"https://api.github.com/users/arokem/following{/other_user}","gists_url":"https://api.github.com/users/arokem/gists{/gist_id}","starred_url":"https://api.github.com/users/arokem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arokem/subscriptions","organizations_url":"https://api.github.com/users/arokem/orgs","repos_url":"https://api.github.com/users/arokem/repos","events_url":"https://api.github.com/users/arokem/events{/privacy}","received_events_url":"https://api.github.com/users/arokem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-11T22:35:40Z","updated_at":"2016-01-11T22:41:12Z","closed_at":null,"body":"The following code throws that error: \r\n\r\n    In [1]: import pandas as pd\r\n    In [2]: import numpy as np\r\n    In [3]: df = pd.DataFrame(np.random.randn(10, 5), columns=['a', 'b', 'c', 'd', 'e'])\r\n    In [4]: import tempfile\r\n    In [5]: tf = tempfile.NamedTemporaryFile()\r\n    In [6]: df.to_csv(tf)\r\n\r\nAm I missing something? \r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/170714634","html_url":"https://github.com/pydata/pandas/issues/12018#issuecomment-170714634","issue_url":"https://api.github.com/repos/pydata/pandas/issues/12018","id":170714634,"user":{"login":"TomAugspurger","id":1312546,"avatar_url":"https://avatars.githubusercontent.com/u/1312546?v=3","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":"2016-01-11T22:41:12Z","updated_at":"2016-01-11T22:41:12Z","body":"You'll want `tf = tempfile.NamedTemporaryFile(mode='w')` or `wt` since you're writing text, not bytes. Check if that works for you?"}}