A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.xarray.dev/en/stable/generated/xarray.Dataset.reset_coords.html below:

xarray.Dataset.reset_coords

xarray.Dataset.reset_coords#
Dataset.reset_coords(names=None, drop=False)[source]#

Given names of coordinates, reset them to become variables

Parameters:
  • names (str, Iterable of Hashable or None, optional) – Name(s) of non-index coordinates in this dataset to reset into variables. By default, all non-index coordinates are reset.

  • drop (bool, default: False) – If True, remove coordinates instead of converting them into variables.

Examples

>>> dataset = xr.Dataset(
...     {
...         "temperature": (
...             ["time", "lat", "lon"],
...             [[[25, 26], [27, 28]], [[29, 30], [31, 32]]],
...         ),
...         "precipitation": (
...             ["time", "lat", "lon"],
...             [[[0.5, 0.8], [0.2, 0.4]], [[0.3, 0.6], [0.7, 0.9]]],
...         ),
...     },
...     coords={
...         "time": pd.date_range(start="2023-01-01", periods=2),
...         "lat": [40, 41],
...         "lon": [-80, -79],
...         "altitude": 1000,
...     },
... )

# Dataset before resetting coordinates

>>> dataset
<xarray.Dataset> Size: 184B
Dimensions:        (time: 2, lat: 2, lon: 2)
Coordinates:
  * time           (time) datetime64[ns] 16B 2023-01-01 2023-01-02
  * lat            (lat) int64 16B 40 41
  * lon            (lon) int64 16B -80 -79
    altitude       int64 8B 1000
Data variables:
    temperature    (time, lat, lon) int64 64B 25 26 27 28 29 30 31 32
    precipitation  (time, lat, lon) float64 64B 0.5 0.8 0.2 0.4 0.3 0.6 0.7 0.9

# Reset the ‘altitude’ coordinate

>>> dataset_reset = dataset.reset_coords("altitude")

# Dataset after resetting coordinates

>>> dataset_reset
<xarray.Dataset> Size: 184B
Dimensions:        (time: 2, lat: 2, lon: 2)
Coordinates:
  * time           (time) datetime64[ns] 16B 2023-01-01 2023-01-02
  * lat            (lat) int64 16B 40 41
  * lon            (lon) int64 16B -80 -79
Data variables:
    temperature    (time, lat, lon) int64 64B 25 26 27 28 29 30 31 32
    precipitation  (time, lat, lon) float64 64B 0.5 0.8 0.2 0.4 0.3 0.6 0.7 0.9
    altitude       int64 8B 1000
Returns:

Dataset


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4