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

Method indexables

pandas/io/pytables.py:3813–3886  ·  view source on GitHub ↗

create/cache the indexables if they don't exist

(self)

Source from the content-addressed store, hash-verified

3811
3812 @cache_readonly
3813 def indexables(self):
3814 """create/cache the indexables if they don't exist"""
3815 _indexables = []
3816
3817 desc = self.description
3818 table_attrs = self.table.attrs
3819
3820 # Note: each of the `name` kwargs below are str, ensured
3821 # by the definition in index_cols.
3822 # index columns
3823 for i, (axis, name) in enumerate(self.attrs.index_cols):
3824 atom = getattr(desc, name)
3825 md = self.read_metadata(name)
3826 meta = "category" if md is not None else None
3827
3828 kind_attr = f"{name}_kind"
3829 kind = getattr(table_attrs, kind_attr, None)
3830
3831 index_col = IndexCol(
3832 name=name,
3833 axis=axis,
3834 pos=i,
3835 kind=kind,
3836 typ=atom,
3837 table=self.table,
3838 meta=meta,
3839 metadata=md,
3840 )
3841 _indexables.append(index_col)
3842
3843 # values columns
3844 dc = set(self.data_columns)
3845 base_pos = len(_indexables)
3846
3847 def f(i, c: str) -> DataCol:
3848 assert isinstance(c, str)
3849 klass = DataCol
3850 if c in dc:
3851 klass = DataIndexableCol
3852
3853 atom = getattr(desc, c)
3854 adj_name = _maybe_adjust_name(c, self.version)
3855
3856 # TODO: why kind_attr here?
3857 values = getattr(table_attrs, f"{adj_name}_kind", None)
3858 dtype = getattr(table_attrs, f"{adj_name}_dtype", None)
3859 # Argument 1 to "_dtype_to_kind" has incompatible type
3860 # "Optional[Any]"; expected "str" [arg-type]
3861 kind = _dtype_to_kind(dtype) # type: ignore[arg-type]
3862
3863 md = self.read_metadata(c)
3864 # TODO: figure out why these two versions of `meta` dont always match.
3865 # meta = "category" if md is not None else None
3866 meta = getattr(table_attrs, f"{adj_name}_meta", None)
3867
3868 obj = klass(
3869 name=adj_name,
3870 cname=c,

Callers

nothing calls this directly

Calls 4

read_metadataMethod · 0.95
IndexColClass · 0.85
fFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected