Skip to content

Commit fd8f5a1

Browse files
committed
feat: Add display configuration methods to DataFrame class
- Introduced `configure_display` method to set customizable display options for DataFrame representation, including maximum bytes, minimum rows, and maximum cell length. - Added `reset_display_config` method to restore default display settings. - Implemented `display_config` property to retrieve current display configuration.
1 parent 17d54cd commit fd8f5a1

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

python/datafusion/dataframe.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,33 @@ def count(self) -> int:
813813
"""
814814
return self.df.count()
815815

816+
def configure_display(
817+
self,
818+
max_table_bytes: Optional[int] = None,
819+
min_table_rows: Optional[int] = None,
820+
max_cell_length: Optional[int] = None,
821+
) -> None:
822+
"""Configure display options for DataFrame representation.
823+
824+
Args:
825+
max_table_bytes: Maximum bytes to display for table presentation (default: 2MB).
826+
Set to lower value for large tables to limit memory usage.
827+
min_table_rows: Minimum number of table rows to display (default: 20).
828+
This is used for initial display and in notebooks.
829+
max_cell_length: Maximum length of a cell before it gets minimized (default: 25).
830+
Longer cells will be truncated with an expand button.
831+
"""
832+
self.df.configure_display(max_table_bytes, min_table_rows, max_cell_length)
833+
834+
def reset_display_config(self) -> None:
835+
"""Reset display configuration to default values."""
836+
self.df.reset_display_config()
837+
838+
@property
839+
def display_config(self):
840+
"""Get the current display configuration."""
841+
return self.df.display_config
842+
816843
@deprecated("Use :py:func:`unnest_columns` instead.")
817844
def unnest_column(self, column: str, preserve_nulls: bool = True) -> DataFrame:
818845
"""See :py:func:`unnest_columns`."""

src/dataframe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ impl PyDataFrame {
882882
}
883883

884884
/// Reset display configuration to default values
885+
#[pyo3(text_signature = "($self)")]
885886
fn reset_display_config(&mut self) {
886887
self.config = Arc::new(DisplayConfig::default());
887888
}

0 commit comments

Comments
 (0)