Skip to content

Commit c5af8e1

Browse files
jorisvandenbosschejreback
authored andcommitted
BUG: fix PeriodConverter issue when given a list of integers (GH9012)
For example coming up when [0, 1] is passed by axhline Restore old behaviour, but special case arrays of Periods to keep the performance gain of using PeriodIndex instead of get_datevalue for that case.
1 parent 39048f6 commit c5af8e1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/tseries/converter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ def convert(values, units, axis):
117117
return values.asfreq(axis.freq).values
118118
if isinstance(values, Index):
119119
return values.map(lambda x: get_datevalue(x, axis.freq))
120-
if isinstance(values, (list, tuple, np.ndarray, Index)):
120+
if com.is_period_arraylike(values):
121121
return PeriodIndex(values, freq=axis.freq).values
122+
if isinstance(values, (list, tuple, np.ndarray, Index)):
123+
return [get_datevalue(x, axis.freq) for x in values]
122124
return values
123125

124126

0 commit comments

Comments
 (0)