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

Method _from_sequence

pandas/core/arrays/period.py:268–293  ·  view source on GitHub ↗
(
        cls,
        scalars,
        *,
        dtype: Dtype | None = None,
        copy: bool = False,
    )

Source from the content-addressed store, hash-verified

266
267 @classmethod
268 def _from_sequence(
269 cls,
270 scalars,
271 *,
272 dtype: Dtype | None = None,
273 copy: bool = False,
274 ) -> Self:
275 if dtype is not None:
276 dtype = pandas_dtype(dtype)
277 if dtype and isinstance(dtype, PeriodDtype):
278 freq = dtype.freq
279 else:
280 freq = None
281
282 if isinstance(scalars, cls):
283 validate_dtype_freq(scalars.dtype, freq)
284 if copy:
285 scalars = scalars.copy()
286 return scalars
287
288 periods = np.asarray(scalars, dtype=object)
289
290 freq = freq or libperiod.extract_freq(periods)
291 ordinals = libperiod.extract_ordinals(periods, freq)
292 dtype = PeriodDtype(freq)
293 return cls(ordinals, dtype=dtype)
294
295 @classmethod
296 def _from_sequence_of_strings(

Callers 15

_reduceMethod · 0.95
_reconstruct_dataFunction · 0.45
arrayFunction · 0.45
sanitize_arrayFunction · 0.45
_sanitize_ndimFunction · 0.45
transposeMethod · 0.45
_str_repeatMethod · 0.45
ndarray_to_mgrFunction · 0.45
convertFunction · 0.45
fast_xsMethod · 0.45
make_na_arrayFunction · 0.45

Calls 5

pandas_dtypeFunction · 0.90
PeriodDtypeClass · 0.90
validate_dtype_freqFunction · 0.85
clsFunction · 0.85
copyMethod · 0.45

Tested by

no test coverage detected