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

Method __init__

pandas/core/series.py:369–519  ·  view source on GitHub ↗
(
        self,
        data=None,
        index=None,
        dtype: Dtype | None = None,
        name=None,
        copy: bool | None = None,
    )

Source from the content-addressed store, hash-verified

367 # Constructors
368
369 def __init__(
370 self,
371 data=None,
372 index=None,
373 dtype: Dtype | None = None,
374 name=None,
375 copy: bool | None = None,
376 ) -> None:
377 allow_mgr = False
378 if (
379 isinstance(data, SingleBlockManager)
380 and index is None
381 and dtype is None
382 and (copy is False or copy is None)
383 ):
384 if not allow_mgr:
385 # GH#52419
386 warnings.warn(
387 f"Passing a {type(data).__name__} to {type(self).__name__} "
388 "is deprecated and will raise in a future version. "
389 "Use public APIs instead.",
390 Pandas4Warning,
391 stacklevel=2,
392 )
393 data = data.copy(deep=False)
394 # GH#33357 called with just the SingleBlockManager
395 NDFrame.__init__(self, data)
396 self.name = name
397 return
398
399 if isinstance(data, (ExtensionArray, np.ndarray)):
400 if copy is not False:
401 if dtype is None or astype_is_view(data.dtype, pandas_dtype(dtype)):
402 data = data.copy()
403 copy = False
404 if copy is None:
405 copy = False
406
407 if isinstance(data, SingleBlockManager) and not copy:
408 data = data.copy(deep=False)
409
410 if not allow_mgr:
411 warnings.warn(
412 f"Passing a {type(data).__name__} to {type(self).__name__} "
413 "is deprecated and will raise in a future version. "
414 "Use public APIs instead.",
415 Pandas4Warning,
416 stacklevel=2,
417 )
418 allow_mgr = True
419
420 name = ibase.maybe_extract_name(name, data, type(self))
421
422 if index is not None:
423 index = ensure_index(index)
424
425 if dtype is not None:
426 dtype = self._validate_dtype(dtype)

Callers

nothing calls this directly

Calls 15

_init_dictMethod · 0.95
astype_is_viewFunction · 0.90
pandas_dtypeFunction · 0.90
default_indexFunction · 0.90
na_value_for_dtypeFunction · 0.90
sanitize_arrayFunction · 0.90
ensure_indexFunction · 0.85
from_arrayMethod · 0.80
_set_axisMethod · 0.80
copyMethod · 0.45
_validate_dtypeMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected