Skip to content

Commit 25f3370

Browse files
Statistics on ParquetFile subset. (#940)
Co-authored-by: Martin Durant <martin.durant@alumni.utoronto.ca>
1 parent 0f7a98e commit 25f3370

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

fastparquet/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def columns(self):
260260

261261
@property
262262
def statistics(self):
263-
if self._statistics is None:
263+
if not hasattr(self, '_statistics') or self._statistics is None:
264264
self._statistics = statistics(self)
265265
return self._statistics
266266

fastparquet/test/test_api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,23 @@ def test_statistics(tempdir):
4444
p = ParquetFile(fn)
4545

4646
s = statistics(p)
47-
expected = {'distinct_count': {'x': [None, None],
47+
expected1 = {'distinct_count': {'x': [None, None],
4848
'y': [None, None],
4949
'z': [None, None]},
5050
'max': {'x': [2, 3], 'y': [2.0, 1.0], 'z': ['b', 'c']},
5151
'min': {'x': [1, 3], 'y': [1.0, 1.0], 'z': ['a', 'c']},
5252
'null_count': {'x': [0, 0], 'y': [0, 0], 'z': [0, 0]}}
5353

54-
assert s == expected
54+
assert s == expected1
55+
56+
expected2 = {'distinct_count': {'x': [None],
57+
'y': [None],
58+
'z': [None]},
59+
'max': {'x': [3], 'y': [1.0], 'z': ['c']},
60+
'min': {'x': [3], 'y': [1.0], 'z': ['c']},
61+
'null_count': {'x': [0], 'y': [0], 'z': [0]}}
62+
63+
assert p[-1].statistics == expected2
5564

5665

5766
def test_logical_types(tempdir):

0 commit comments

Comments
 (0)