MCPcopy
hub / github.com/pandas-dev/pandas / _convert_1d

Method _convert_1d

pandas/plotting/_matplotlib/converter.py:249–274  ·  view source on GitHub ↗
(values, freq: BaseOffset)

Source from the content-addressed store, hash-verified

247
248 @staticmethod
249 def _convert_1d(values, freq: BaseOffset):
250 valid_types = (str, datetime, Period, pydt.date, np.datetime64)
251 with warnings.catch_warnings():
252 warnings.filterwarnings(
253 "ignore", "Period with BDay freq is deprecated", category=FutureWarning
254 )
255 warnings.filterwarnings(
256 "ignore", r"PeriodDtype\[B\] is deprecated", category=FutureWarning
257 )
258 if (
259 isinstance(values, valid_types)
260 or is_integer(values)
261 or is_float(values)
262 ):
263 return _get_datevalue(values, freq)
264 elif isinstance(values, PeriodIndex):
265 return values.asfreq(freq).asi8
266 elif isinstance(values, Index):
267 return values.map(lambda x: _get_datevalue(x, freq))
268 elif lib.infer_dtype(values, skipna=False) == "period":
269 # https://github.com/pandas-dev/pandas/issues/24304
270 # convert ndarray[period] -> PeriodIndex
271 return PeriodIndex(values, freq=freq).asi8
272 elif isinstance(values, (list, tuple, np.ndarray)):
273 return [_get_datevalue(x, freq) for x in values]
274 return values
275
276
277def _get_datevalue(date, freq: BaseOffset):

Callers 2

convert_from_freqMethod · 0.45
convertMethod · 0.45

Calls 4

PeriodIndexClass · 0.90
_get_datevalueFunction · 0.85
asfreqMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected