(
self,
data=None,
index=None,
dtype: Dtype | None = None,
name=None,
copy: bool | None = None,
)
| 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) |
nothing calls this directly
no test coverage detected