diff --git a/eland/dataframe.py b/eland/dataframe.py index 33164da..f9a18b4 100644 --- a/eland/dataframe.py +++ b/eland/dataframe.py @@ -244,13 +244,22 @@ class DataFrame(NDFrame): """ buf = StringIO() + # max_rows and max_cols determine the maximum size of the pretty printed tabular + # representation of the dataframe. pandas defaults are 60 and 20 respectively. + # dataframes where len(df) > max_rows shows a truncated view with 10 rows shown. max_rows = pd.get_option("display.max_rows") max_cols = pd.get_option("display.max_columns") + min_rows = pd.get_option("display.min_rows") + + if len(self) > max_rows: + max_rows = min_rows + show_dimensions = pd.get_option("display.show_dimensions") if pd.get_option("display.expand_frame_repr"): width, _ = console.get_console_size() else: width = None + self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols, line_width=width, show_dimensions=show_dimensions) diff --git a/eland/tests/dataframe/test_repr_pytest.py b/eland/tests/dataframe/test_repr_pytest.py index 8210af0..27ce50c 100644 --- a/eland/tests/dataframe/test_repr_pytest.py +++ b/eland/tests/dataframe/test_repr_pytest.py @@ -33,6 +33,18 @@ class TestDataFrameRepr(TestData): assert pd_head_11_str == ed_head_11_str + def test_less_than_max_rows_to_string(self): + ed_flights = self.ed_flights() + pd_flights = self.pd_flights() + + ed_less_than_max = ed_flights[ed_flights['AvgTicketPrice']>1190] + pd_less_than_max = pd_flights[pd_flights['AvgTicketPrice']>1190] + + ed_less_than_max_str = ed_less_than_max.to_string() + pd_less_than_max_str = pd_less_than_max.to_string() + + assert pd_less_than_max_str == ed_less_than_max_str + def test_repr(self): ed_ecommerce = self.ed_ecommerce() pd_ecommerce = self.pd_ecommerce()