From c90602dd6558eac00956c00562c9eacb390d8861 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 19 Nov 2019 15:13:18 -0500 Subject: [PATCH] sets max_rows=1 in case of empty dataframe --- eland/dataframe.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/eland/dataframe.py b/eland/dataframe.py index c724f6e..bf9e3d6 100644 --- a/eland/dataframe.py +++ b/eland/dataframe.py @@ -580,6 +580,11 @@ class DataFrame(NDFrame): UserWarning) max_rows = DEFAULT_NUM_ROWS_DISPLAYED + # because of the way pandas handles max_rows=0, not having this throws an error + # see eland issue #56 + if max_rows == 0: + max_rows = 1 + # Create a slightly bigger dataframe than display df = self._build_repr_df(max_rows + 1, max_cols) @@ -640,6 +645,11 @@ class DataFrame(NDFrame): UserWarning) max_rows = DEFAULT_NUM_ROWS_DISPLAYED + # because of the way pandas handles max_rows=0, not having this throws an error + # see eland issue #56 + if max_rows == 0: + max_rows = 1 + # Create a slightly bigger dataframe than display df = self._build_repr_df(max_rows + 1, max_cols) @@ -661,6 +671,10 @@ class DataFrame(NDFrame): decimal=decimal, line_width=line_width) + # dimensions are not show in the terminal, but they are shown in jupyter + if len(self) == 0: + show_dimensions=False + # Our fake dataframe has incorrect number of rows (max_rows*2+1) - write out # the correct number of rows if show_dimensions: