Skip to content

Commit 57c791c

Browse files
committed
REF: privatize get_datevalue
1 parent 22bae73 commit 57c791c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pandas/plotting/_matplotlib/converter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,21 @@ def _convert_1d(values, freq):
252252
or is_integer(values)
253253
or is_float(values)
254254
):
255-
return get_datevalue(values, freq)
255+
return _get_datevalue(values, freq)
256256
elif isinstance(values, PeriodIndex):
257257
return values.asfreq(freq).asi8
258258
elif isinstance(values, Index):
259-
return values.map(lambda x: get_datevalue(x, freq))
259+
return values.map(lambda x: _get_datevalue(x, freq))
260260
elif lib.infer_dtype(values, skipna=False) == "period":
261261
# https://github.com/pandas-dev/pandas/issues/24304
262262
# convert ndarray[period] -> PeriodIndex
263263
return PeriodIndex(values, freq=freq).asi8
264264
elif isinstance(values, (list, tuple, np.ndarray, Index)):
265-
return [get_datevalue(x, freq) for x in values]
265+
return [_get_datevalue(x, freq) for x in values]
266266
return values
267267

268268

269-
def get_datevalue(date, freq):
269+
def _get_datevalue(date, freq):
270270
if isinstance(date, Period):
271271
return date.asfreq(freq).ordinal
272272
elif isinstance(date, (str, datetime, pydt.date, pydt.time, np.datetime64)):

pandas/tests/plotting/test_datetimelike.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,13 @@ def test_high_freq(self, freq):
165165
_check_plot_works(ser.plot, ax=ax)
166166

167167
def test_get_datevalue(self):
168-
assert conv.get_datevalue(None, "D") is None
169-
assert conv.get_datevalue(1987, "Y") == 1987
168+
assert conv._get_datevalue(None, "D") is None
169+
assert conv._get_datevalue(1987, "Y") == 1987
170170
assert (
171-
conv.get_datevalue(Period(1987, "Y"), "M") == Period("1987-12", "M").ordinal
171+
conv._get_datevalue(Period(1987, "Y"), "M")
172+
== Period("1987-12", "M").ordinal
172173
)
173-
assert conv.get_datevalue("1/1/1987", "D") == Period("1987-1-1", "D").ordinal
174+
assert conv._get_datevalue("1/1/1987", "D") == Period("1987-1-1", "D").ordinal
174175

175176
@pytest.mark.parametrize(
176177
"freq, expected_string",

0 commit comments

Comments
 (0)