diff --git a/modin/core/storage_formats/base/query_compiler.py b/modin/core/storage_formats/base/query_compiler.py index 752599df5b4..343008d2a3d 100644 --- a/modin/core/storage_formats/base/query_compiler.py +++ b/modin/core/storage_formats/base/query_compiler.py @@ -135,8 +135,6 @@ class BaseQueryCompiler( lazy_column_count : bool, default False True if the backend defers computations of the number of columns (`len(df.columns)`). Used by the frontend to avoid unnecessary execution or defer error validation. - lazy_shape : bool - True if either lazy_row_count or lazy_column_count is True. _shape_hint : {"row", "column", None}, default: None Shape hint for frames known to be a column or a row, otherwise None. @@ -218,6 +216,15 @@ def default_to_pandas(self, pandas_op, *args, **kwargs) -> Self: @property def lazy_shape(self): + """ + Whether either of the underlying dataframe's dimensions (row count/column count) are computed lazily. + + If True, the frontend should avoid length/shape checks as much as possible. + + Returns + ------- + bool + """ return self.lazy_row_count or self.lazy_column_count _shape_hint = None diff --git a/modin/core/storage_formats/pandas/query_compiler.py b/modin/core/storage_formats/pandas/query_compiler.py index 124486a786d..3581516a638 100644 --- a/modin/core/storage_formats/pandas/query_compiler.py +++ b/modin/core/storage_formats/pandas/query_compiler.py @@ -277,22 +277,67 @@ def __init__(self, modin_frame: PandasDataframe, shape_hint: Optional[str] = Non @property def lazy_row_labels(self): + """ + Whether the row labels are computed lazily. + + Equivalent to `not self.frame_has_materialized_index`. + + Returns + ------- + bool + """ return not self.frame_has_materialized_index @property def lazy_row_count(self): + """ + Whether the row count is computed lazily. + + Equivalent to `not self.frame_has_materialized_index`. + + Returns + ------- + bool + """ return not self.frame_has_materialized_index @property def lazy_column_types(self): + """ + Whether the dtypes are computed lazily. + + Equivalent to `not self.frame_has_materialized_dtypes`. + + Returns + ------- + bool + """ return not self.frame_has_materialized_dtypes @property def lazy_column_labels(self): + """ + Whether the column labels are computed lazily. + + Equivalent to `not self.frame_has_materialized_columns`. + + Returns + ------- + bool + """ return not self.frame_has_materialized_columns @property def lazy_column_count(self): + """ + Whether the column count is are computed lazily. + + Equivalent to `not self.frame_has_materialized_columns`. + + Returns + ------- + bool + """ return not self.frame_has_materialized_columns def finalize(self): @@ -1803,9 +1848,7 @@ def get_unique_level_values(index): new_index = ( get_unique_level_values(index) if consider_index - else index - if isinstance(index, list) - else [index] + else index if isinstance(index, list) else [index] ) new_columns = (