Skip to content

Commit 1635b73

Browse files
committed
try this
1 parent 5a2e1e4 commit 1635b73

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pandas/io/formats/format.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,14 @@ def _format_strings(self):
11291129
values = values._values
11301130

11311131
formatter = values._formatter(self)
1132-
fmt_values = format_array(np.asarray(values),
1132+
1133+
if is_categorical_dtype(values.dtype):
1134+
# Categorical is special for now, so that we can preserve tzinfo
1135+
array = values.get_values()
1136+
else:
1137+
array = np.asarray(values)
1138+
1139+
fmt_values = format_array(array,
11331140
formatter,
11341141
float_format=self.float_format,
11351142
na_rep=self.na_rep, digits=self.digits,

pandas/tests/frame/test_repr_info.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,12 @@ def test_repr_categorical_dates_periods(self):
514514
tz='US/Eastern')
515515
p = period_range('2011-01', freq='M', periods=5)
516516
df = DataFrame({'dt': dt, 'p': p})
517-
exp = """ dt p
518-
0 2011-01-01 09:00:00-05:00 2011-01
519-
1 2011-01-01 10:00:00-05:00 2011-02
520-
2 2011-01-01 11:00:00-05:00 2011-03
521-
3 2011-01-01 12:00:00-05:00 2011-04
522-
4 2011-01-01 13:00:00-05:00 2011-05"""
517+
exp = """ dt p
518+
0 2011-01-01 09:00:00-05:00 2011-01
519+
1 2011-01-01 10:00:00-05:00 2011-02
520+
2 2011-01-01 11:00:00-05:00 2011-03
521+
3 2011-01-01 12:00:00-05:00 2011-04
522+
4 2011-01-01 13:00:00-05:00 2011-05"""
523523

524524
df = DataFrame({'dt': Categorical(dt), 'p': Categorical(p)})
525525
assert repr(df) == exp

0 commit comments

Comments
 (0)