|
22 | 22 |
|
23 | 23 | import datetime |
24 | 24 | import re |
| 25 | +from abc import ABC, abstractmethod |
25 | 26 | from functools import cached_property |
26 | 27 | from typing import TYPE_CHECKING, Callable, Dict, Hashable, List, Optional, Union |
27 | 28 |
|
|
33 | 34 | from pandas.core.indexes.api import Index, RangeIndex |
34 | 35 |
|
35 | 36 | from modin.config import ( |
36 | | - Engine, |
37 | 37 | IsRayCluster, |
38 | 38 | MinColumnPartitionSize, |
39 | 39 | MinRowPartitionSize, |
|
80 | 80 |
|
81 | 81 |
|
82 | 82 | class PandasDataframe( |
83 | | - ClassLogger, modin_layer="CORE-DATAFRAME", log_level=LogLevel.DEBUG |
| 83 | + ABC, ClassLogger, modin_layer="CORE-DATAFRAME", log_level=LogLevel.DEBUG |
84 | 84 | ): |
85 | 85 | """ |
86 | 86 | An abstract class that represents the parent class for any pandas storage format dataframe class. |
@@ -122,6 +122,31 @@ class PandasDataframe( |
122 | 122 | _dtypes: Optional[ModinDtypes] = None |
123 | 123 | _pandas_backend: Optional[str] = None |
124 | 124 |
|
| 125 | + @property |
| 126 | + def storage_format(self) -> str: |
| 127 | + """ |
| 128 | + The storage format for this frame's data. |
| 129 | +
|
| 130 | + Returns |
| 131 | + ------- |
| 132 | + str |
| 133 | + The storage format. |
| 134 | + """ |
| 135 | + return "Pandas" |
| 136 | + |
| 137 | + @property |
| 138 | + @abstractmethod |
| 139 | + def engine(self) -> str: |
| 140 | + """ |
| 141 | + The engine for this frame. |
| 142 | +
|
| 143 | + Returns |
| 144 | + ------- |
| 145 | + str |
| 146 | + The engine. |
| 147 | + """ |
| 148 | + pass |
| 149 | + |
125 | 150 | @cached_property |
126 | 151 | def __constructor__(self) -> type[PandasDataframe]: |
127 | 152 | """ |
@@ -1707,7 +1732,7 @@ def astype(self, col_dtypes, errors: str = "raise"): |
1707 | 1732 | new_dtypes = self_dtypes.copy() |
1708 | 1733 | # Update the new dtype series to the proper pandas dtype |
1709 | 1734 | new_dtype = pandas.api.types.pandas_dtype(dtype) |
1710 | | - if Engine.get() == "Dask" and hasattr(dtype, "_is_materialized"): |
| 1735 | + if self.engine == "Dask" and hasattr(dtype, "_is_materialized"): |
1711 | 1736 | # FIXME: https://github.com/dask/distributed/issues/8585 |
1712 | 1737 | _ = dtype._materialize_categories() |
1713 | 1738 |
|
@@ -1736,7 +1761,7 @@ def astype_builder(df): |
1736 | 1761 | if not (col_dtypes == self_dtypes).all(): |
1737 | 1762 | new_dtypes = self_dtypes.copy() |
1738 | 1763 | new_dtype = pandas.api.types.pandas_dtype(col_dtypes) |
1739 | | - if Engine.get() == "Dask" and hasattr(new_dtype, "_is_materialized"): |
| 1764 | + if self.engine == "Dask" and hasattr(new_dtype, "_is_materialized"): |
1740 | 1765 | # FIXME: https://github.com/dask/distributed/issues/8585 |
1741 | 1766 | _ = new_dtype._materialize_categories() |
1742 | 1767 | if isinstance(new_dtype, pandas.CategoricalDtype): |
|
0 commit comments