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

Method _get_atom

pandas/io/pytables.py:2571–2600  ·  view source on GitHub ↗

Get an appropriately typed and shaped pytables.Col object for values.

(cls, values: ArrayLike)

Source from the content-addressed store, hash-verified

2569
2570 @classmethod
2571 def _get_atom(cls, values: ArrayLike) -> Col:
2572 """
2573 Get an appropriately typed and shaped pytables.Col object for values.
2574 """
2575 dtype = values.dtype
2576 # error: Item "ExtensionDtype" of "Union[ExtensionDtype, dtype[Any]]" has no
2577 # attribute "itemsize"
2578 itemsize = dtype.itemsize # type: ignore[union-attr]
2579
2580 shape = values.shape
2581 if values.ndim == 1:
2582 # EA, use block shape pretending it is 2D
2583 # TODO(EA2D): not necessary with 2D EAs
2584 shape = (1, values.size)
2585
2586 if isinstance(values, Categorical):
2587 codes = values.codes
2588 atom = cls.get_atom_data(shape, kind=codes.dtype.name)
2589 elif lib.is_np_dtype(dtype, "M") or isinstance(dtype, DatetimeTZDtype):
2590 atom = cls.get_atom_datetime64(shape)
2591 elif lib.is_np_dtype(dtype, "m"):
2592 atom = cls.get_atom_timedelta64(shape)
2593 elif is_complex_dtype(dtype):
2594 atom = _tables().ComplexCol(itemsize=itemsize, shape=shape[0])
2595 elif is_string_dtype(dtype):
2596 atom = cls.get_atom_string(shape, itemsize)
2597 else:
2598 atom = cls.get_atom_data(shape, kind=dtype.name)
2599
2600 return atom
2601
2602 @classmethod
2603 def get_atom_string(cls, shape, itemsize):

Callers 2

_create_axesMethod · 0.80
_convert_indexFunction · 0.80

Calls 7

is_complex_dtypeFunction · 0.90
is_string_dtypeFunction · 0.90
_tablesFunction · 0.85
get_atom_dataMethod · 0.45
get_atom_datetime64Method · 0.45
get_atom_timedelta64Method · 0.45
get_atom_stringMethod · 0.45

Tested by

no test coverage detected