File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 7
7
8
8
from pandas ._libs .tslibs import Period , to_offset
9
9
from pandas ._libs .tslibs .frequencies import FreqGroup , base_and_stride , get_freq_code
10
+ from pandas ._typing import FrameOrSeriesUnion
10
11
11
12
from pandas .core .dtypes .generic import (
12
13
ABCDatetimeIndex ,
@@ -192,7 +193,7 @@ def _get_freq(ax, series: "Series"):
192
193
return freq , ax_freq
193
194
194
195
195
- def _use_dynamic_x (ax , data ) :
196
+ def _use_dynamic_x (ax , data : "FrameOrSeriesUnion" ) -> bool :
196
197
freq = _get_index_freq (data .index )
197
198
ax_freq = _get_ax_freq (ax )
198
199
Original file line number Diff line number Diff line change 16
16
from pandas .core .resample import DatetimeIndex
17
17
from pandas .tests .plotting .common import TestPlotBase
18
18
19
- from pandas .tseries .offsets import DateOffset
19
+ from pandas .tseries .offsets import DateOffset , WeekOfMonth
20
20
21
21
22
22
@td .skip_if_no_mpl
@@ -325,6 +325,18 @@ def test_business_freq_convert(self):
325
325
idx = ax .get_lines ()[0 ].get_xdata ()
326
326
assert PeriodIndex (data = idx ).freqstr == "M"
327
327
328
+ def test_freq_with_no_period_alias (self ):
329
+ # GH34487
330
+ freq = WeekOfMonth ()
331
+ bts = tm .makeTimeSeries (5 ).asfreq (freq )
332
+ _ , ax = self .plt .subplots ()
333
+ bts .plot (ax = ax )
334
+ assert ax .get_lines ()[0 ].get_xydata ()[0 , 0 ] == bts .index [0 ].toordinal ()
335
+ idx = ax .get_lines ()[0 ].get_xdata ()
336
+ msg = "freq not specified and cannot be inferred"
337
+ with pytest .raises (ValueError , match = msg ):
338
+ PeriodIndex (data = idx )
339
+
328
340
def test_nonzero_base (self ):
329
341
# GH2571
330
342
idx = date_range ("2012-12-20" , periods = 24 , freq = "H" ) + timedelta (minutes = 30 )
You can’t perform that action at this time.
0 commit comments