MCPcopy
hub / github.com/pydata/xarray / create_variables

Method create_variables

xarray/core/indexes.py:172–203  ·  view source on GitHub ↗

Maybe create new coordinate variables from this index. This method is useful if the index data can be reused as coordinate variable data. It is often the case when the underlying index structure has an array-like interface, like :py:class:`pandas.Index` objects. The

(
        self, variables: Mapping[Any, Variable] | None = None
    )

Source from the content-addressed store, hash-verified

170 raise NotImplementedError()
171
172 def create_variables(
173 self, variables: Mapping[Any, Variable] | None = None
174 ) -> IndexVars:
175 """Maybe create new coordinate variables from this index.
176
177 This method is useful if the index data can be reused as coordinate
178 variable data. It is often the case when the underlying index structure
179 has an array-like interface, like :py:class:`pandas.Index` objects.
180
181 The variables given as argument (if any) are either returned as-is
182 (default behavior) or can be used to copy their metadata (attributes and
183 encoding) into the new returned coordinate variables.
184
185 Note: the input variables may or may not have been filtered for this
186 index.
187
188 Parameters
189 ----------
190 variables : dict-like, optional
191 Mapping of :py:class:`Variable` objects.
192
193 Returns
194 -------
195 index_variables : dict-like
196 Dictionary of :py:class:`Variable` or :py:class:`IndexVariable`
197 objects.
198 """
199 if variables is not None:
200 # pass through
201 return dict(**variables)
202 else:
203 return {}
204
205 def should_add_coord_to_array(
206 self,

Callers 15

_rename_indexesMethod · 0.45
set_indexMethod · 0.45
reset_indexMethod · 0.45
set_xindexMethod · 0.45
reorder_levelsMethod · 0.45
_stack_onceMethod · 0.45
_unstack_onceMethod · 0.45
_unstack_full_reindexMethod · 0.45
padMethod · 0.45
drop_attrsMethod · 0.45
from_xindexMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected