From 73cc3c84b437a92ee9220207efee9b740e3adb40 Mon Sep 17 00:00:00 2001 From: TomAugspurger Date: Thu, 26 Feb 2015 20:26:57 -0600 Subject: [PATCH] BUG: Fix read_csv on S3 files for python 3 Needed to pass along encoding parameter. Bump boto version. Enable test on py3 --- ci/requirements-2.7.txt | 2 +- doc/source/whatsnew/v0.16.0.txt | 4 ++++ pandas/io/common.py | 3 ++- pandas/io/tests/test_parsers.py | 3 --- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ci/requirements-2.7.txt b/ci/requirements-2.7.txt index f3df26e7a0c24..0d515f300f5a7 100644 --- a/ci/requirements-2.7.txt +++ b/ci/requirements-2.7.txt @@ -13,7 +13,7 @@ lxml=3.2.1 scipy xlsxwriter=0.4.6 statsmodels -boto=2.26.1 +boto=2.36.0 bottleneck=0.8.0 psycopg2=2.5.2 patsy diff --git a/doc/source/whatsnew/v0.16.0.txt b/doc/source/whatsnew/v0.16.0.txt index ead3c79430bf9..5b3d67957730e 100644 --- a/doc/source/whatsnew/v0.16.0.txt +++ b/doc/source/whatsnew/v0.16.0.txt @@ -344,3 +344,7 @@ Bug Fixes - Bug in groupby MultiIndex with missing pair (:issue:`9049`, :issue:`9344`) - Fixed bug in ``Series.groupby`` where grouping on ``MultiIndex`` levels would ignore the sort argument (:issue:`9444`) - Fix bug in ``DataFrame.Groupby`` where sort=False is ignored in case of Categorical columns. (:issue:`8868`) + + + +- Fixed bug with reading CSV files from Amazon S3 on python 3 raising a TypeError (:issue:`9452`) diff --git a/pandas/io/common.py b/pandas/io/common.py index 737a55a6752c1..65cfdff1df14b 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -154,7 +154,8 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None): b = conn.get_bucket(parsed_url.netloc) k = boto.s3.key.Key(b) k.key = parsed_url.path - filepath_or_buffer = BytesIO(k.get_contents_as_string()) + filepath_or_buffer = BytesIO(k.get_contents_as_string( + encoding=encoding)) return filepath_or_buffer, None diff --git a/pandas/io/tests/test_parsers.py b/pandas/io/tests/test_parsers.py index bf68460364ef4..35530a7f5e07f 100644 --- a/pandas/io/tests/test_parsers.py +++ b/pandas/io/tests/test_parsers.py @@ -3802,9 +3802,6 @@ def setUp(self): except ImportError: raise nose.SkipTest("boto not installed") - if compat.PY3: - raise nose.SkipTest("boto incompatible with Python 3") - @tm.network def test_parse_public_s3_bucket(self): import nose.tools as nt