|
66 | 66 | import pandas.core.missing as missing
|
67 | 67 | from pandas.core.base import PandasObject
|
68 | 68 |
|
69 |
| -from pandas.core.arrays import Categorical |
| 69 | +from pandas.core.arrays import Categorical, ExtensionArray |
70 | 70 |
|
71 | 71 | from pandas.core.indexes.datetimes import DatetimeIndex
|
72 | 72 | from pandas.core.indexes.timedeltas import TimedeltaIndex
|
@@ -1951,7 +1951,21 @@ def _slice(self, slicer):
|
1951 | 1951 | return self.values[slicer]
|
1952 | 1952 |
|
1953 | 1953 | def formatting_values(self):
|
1954 |
| - return self.values._formatting_values() |
| 1954 | + # Deprecating the ability to override _formatting_values. |
| 1955 | + # Do the warning here, it's only user in pandas, since we |
| 1956 | + # have to check if the subclass overrode it. |
| 1957 | + fv = getattr(type(self.values), '_formatting_values', None) |
| 1958 | + if fv is not ExtensionArray._formatting_values: |
| 1959 | + msg = ( |
| 1960 | + "'ExtensionArray._formatting_values' is deprecated. " |
| 1961 | + "Specify 'ExtensionArray._formatter' instead." |
| 1962 | + ) |
| 1963 | + warnings.warn(msg, FutureWarning) |
| 1964 | + return self.values._formatting_values() |
| 1965 | + |
| 1966 | + # the future implementation (and current, if not overrode) |
| 1967 | + formatter = self.values._formatter(boxed=True) |
| 1968 | + return np.array([formatter(x) for x in self.values], dtype=object) |
1955 | 1969 |
|
1956 | 1970 | def concat_same_type(self, to_concat, placement=None):
|
1957 | 1971 | """
|
|
0 commit comments