Skip to content

Commit

Permalink
Address @gfyoung reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Aug 10, 2017
1 parent 3432915 commit b860ffe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Other Enhancements
- :func:`date_range` now accepts 'Y' in addition to 'A' as an alias for end of year (:issue:`9313`)
- Integration with `Apache Parquet <https://parquet.apache.org/>`__, including a new top-level :func:`read_parquet` and :func:`DataFrame.to_parquet` method, see :ref:`here <io.parquet>`.
- :func:`DataFrame.add_prefix` and :func:`DataFrame.add_suffix` now accept strings containing the '%' character. (:issue:`17151`)
- :func:`read_csv` can now infer compression from non-string paths, such as a ``pathlab.Path`` objects (:issue:`17206`).
- :func:`read_csv` can now infer compression from non-string paths, such as a ``pathlib.Path`` objects (:issue:`17206`).

.. _whatsnew_0210.api_breaking:

Expand Down
19 changes: 8 additions & 11 deletions pandas/tests/io/parser/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,17 @@ def test_read_csv_infer_compression(self):

inputs[3].close()

def test_read_csv_infer_compression_pathlib(self):
@pytest.mark.parametrize('extension', ['', '.gz', '.bz2'])
def test_read_csv_infer_compression_pathlib(self, extension):
"""
Test that compression is inferred from pathlib.Path paths.
"""
try:
import pathlib
except ImportError:
pytest.skip('need pathlib to run')
expected = self.read_csv(self.csv1, index_col=0, parse_dates=True)
for extension in '', '.gz', '.bz2':
path = pathlib.Path(self.csv1 + extension)
df = self.read_csv(
path, index_col=0, parse_dates=True, compression='infer')
tm.assert_frame_equal(expected, df)
pathlib = pytest.importskip('pathlib')
read_csv_kwargs = {'index_col': 0, 'parse_dates': True}
expected = self.read_csv(self.csv1, **read_csv_kwargs)
path = pathlib.Path(self.csv1 + extension)
df = self.read_csv(path, compression='infer', **read_csv_kwargs)
tm.assert_frame_equal(expected, df)

def test_invalid_compression(self):
msg = 'Unrecognized compression type: sfark'
Expand Down

0 comments on commit b860ffe

Please sign in to comment.