Skip to content

Commit 9c8cfb7

Browse files
committed
Fix linting issues
1 parent 1496ef6 commit 9c8cfb7

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

pandas/io/parquet.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from warnings import catch_warnings
44
from distutils.version import LooseVersion
55
from pandas import DataFrame, RangeIndex, Int64Index, get_option
6-
from pandas.compat import range, string_types
6+
from pandas.compat import string_types
77
from pandas.core.common import AbstractMethodError
88
from pandas.io.common import get_filepath_or_buffer
99

@@ -87,7 +87,7 @@ def __init__(self):
8787
"pip install -U pyarrow\n"
8888
)
8989
self._pyarrow_lt_070 = (
90-
LooseVersion(pyarrow.__version__) < LooseVersion('0.7.0')
90+
LooseVersion(pyarrow.__version__) < LooseVersion('0.7.0')
9191
)
9292
self.api = pyarrow
9393

@@ -113,14 +113,16 @@ def read(self, path, columns=None, **kwargs):
113113
kwargs['use_pandas_metadata'] = True
114114
return parquet_file.read(columns=columns, **kwargs).to_pandas()
115115

116-
117116
def _validate_write_lt_070(self, df, path, compression='snappy',
118-
coerce_timestamps='ms', **kwargs):
117+
coerce_timestamps='ms', **kwargs):
119118
# Compatibility shim for pyarrow < 0.7.0
120119
# TODO: Remove in pandas 0.22.0
121120
from pandas.core.indexes.multi import MultiIndex
122121
if isinstance(df.index, MultiIndex):
123-
msg = "Mulit-index DataFrames are only supported with pyarrow >= 0.7.0"
122+
msg = (
123+
"Mulit-index DataFrames are only supported "
124+
"with pyarrow >= 0.7.0"
125+
)
124126
raise ValueError(msg)
125127
# Validate index
126128
if not isinstance(df.index, Int64Index):
@@ -150,7 +152,8 @@ def _read_lt_070(self, parquet_file, columns, **kwargs):
150152
metadata = json.loads(parquet_file.metadata.metadata[b'pandas'])
151153
columns = set(chain(columns, metadata['index_columns']))
152154
kwargs['columns'] = columns
153-
return self.api.parquet.read_table(parquet_file.path, **kwargs).to_pandas()
155+
kwargs['path'] = parquet_file.path
156+
return self.api.parquet.read_table(**kwargs).to_pandas()
154157

155158

156159
class FastParquetImpl(BaseImpl):

pandas/tests/io/test_parquet.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def test_read_columns(self, engine):
258258

259259
def test_write_with_index(self, engine):
260260
check_names = engine != 'fastparquet'
261-
261+
262262
df = pd.DataFrame({'A': [1, 2, 3]})
263263
self.check_round_trip(df, engine, write_kwargs={'compression': None})
264264

@@ -278,7 +278,7 @@ def test_write_with_index(self, engine):
278278
)
279279
if engine != 'fastparquet':
280280
# Not suppoprted in fastparquet as of 0.1.3
281-
index = pd.MultiIndex.from_tuples([('a', 1), ('a', 2), ('b', 1)])
281+
index = pd.MultiIndex.from_tuples([('a', 1), ('a', 2), ('b', 1)])
282282
df.index = index
283283
self.check_round_trip(
284284
df, engine,
@@ -299,10 +299,11 @@ def test_write_with_index(self, engine):
299299

300300
def test_multiindex_with_columns(self, engine):
301301
if engine == 'fastparquet':
302-
pytest.xfail("fastparquet doesn't support mulit-indexes as of 0.1.3")
302+
msg = "fastparquet doesn't support mulit-indexes as of 0.1.3"
303+
pytest.xfail(msg)
303304

304305
dates = pd.date_range('01-Jan-2018', '01-Dec-2018', freq='MS')
305-
df = pd.DataFrame(randn(2*len(dates), 3), columns=list('ABC'))
306+
df = pd.DataFrame(randn(2 * len(dates), 3), columns=list('ABC'))
306307
index1 = pd.MultiIndex.from_product(
307308
[['Level1', 'Level2'], dates],
308309
names=['level', 'date']

0 commit comments

Comments
 (0)