|
18 | 18 | from pandas.core.dtypes.common import (
|
19 | 19 | is_categorical_dtype, is_datetime64_dtype, is_datetimetz,
|
20 | 20 | is_extension_array_dtype, is_float, is_float_dtype, is_integer,
|
21 |
| - is_integer_dtype, is_list_like, is_numeric_dtype, is_period_arraylike, |
22 |
| - is_scalar, is_timedelta64_dtype) |
| 21 | + is_integer_dtype, is_list_like, is_numeric_dtype, is_scalar, |
| 22 | + is_timedelta64_dtype) |
23 | 23 | from pandas.core.dtypes.generic import (
|
24 |
| - ABCIndex, ABCMultiIndex, ABCSeries, ABCSparseArray) |
| 24 | + ABCIndexClass, ABCMultiIndex, ABCSeries, ABCSparseArray) |
25 | 25 | from pandas.core.dtypes.missing import isna, notna
|
26 | 26 |
|
27 | 27 | from pandas import compat
|
|
30 | 30 | from pandas.core.config import get_option, set_option
|
31 | 31 | from pandas.core.index import Index, ensure_index
|
32 | 32 | from pandas.core.indexes.datetimes import DatetimeIndex
|
33 |
| -from pandas.core.indexes.period import PeriodIndex |
34 | 33 |
|
35 | 34 | from pandas.io.common import _expand_user, _stringify_path
|
36 | 35 | from pandas.io.formats.printing import adjoin, justify, pprint_thing
|
@@ -850,9 +849,7 @@ def _get_column_name_list(self):
|
850 | 849 | def format_array(values, formatter, float_format=None, na_rep='NaN',
|
851 | 850 | digits=None, space=None, justify='right', decimal='.'):
|
852 | 851 |
|
853 |
| - if is_period_arraylike(values): |
854 |
| - fmt_klass = PeriodArrayFormatter |
855 |
| - elif is_datetime64_dtype(values.dtype): |
| 852 | + if is_datetime64_dtype(values.dtype): |
856 | 853 | fmt_klass = Datetime64Formatter
|
857 | 854 | elif is_timedelta64_dtype(values.dtype):
|
858 | 855 | fmt_klass = Timedelta64Formatter
|
@@ -1128,33 +1125,18 @@ def _format_strings(self):
|
1128 | 1125 | class ExtensionArrayFormatter(GenericArrayFormatter):
|
1129 | 1126 | def _format_strings(self):
|
1130 | 1127 | values = self.values
|
1131 |
| - if isinstance(values, (ABCIndex, ABCSeries)): |
| 1128 | + if isinstance(values, (ABCIndexClass, ABCSeries)): |
1132 | 1129 | values = values._values
|
1133 | 1130 |
|
1134 |
| - formatter = self.values._formatter(self) |
1135 |
| - fmt_values = format_array(np.asarray(self.values), |
| 1131 | + formatter = values._formatter(self) |
| 1132 | + fmt_values = format_array(np.asarray(values), |
1136 | 1133 | formatter,
|
1137 | 1134 | float_format=self.float_format,
|
1138 | 1135 | na_rep=self.na_rep, digits=self.digits,
|
1139 | 1136 | space=self.space, justify=self.justify)
|
1140 | 1137 | return fmt_values
|
1141 | 1138 |
|
1142 | 1139 |
|
1143 |
| -class PeriodArrayFormatter(IntArrayFormatter): |
1144 |
| - |
1145 |
| - def _format_strings(self): |
1146 |
| - from pandas.core.indexes.period import IncompatibleFrequency |
1147 |
| - try: |
1148 |
| - values = PeriodIndex(self.values).to_native_types() |
1149 |
| - except IncompatibleFrequency: |
1150 |
| - # periods may contains different freq |
1151 |
| - values = Index(self.values, dtype='object').to_native_types() |
1152 |
| - |
1153 |
| - formatter = self.formatter or (lambda x: '{x}'.format(x=x)) |
1154 |
| - fmt_values = [formatter(x) for x in values] |
1155 |
| - return fmt_values |
1156 |
| - |
1157 |
| - |
1158 | 1140 | def format_percentiles(percentiles):
|
1159 | 1141 | """
|
1160 | 1142 | Outputs rounded and formatted percentiles.
|
|
0 commit comments