0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【xarray】形状を引き継いだ新しい配列を作る① (zeros_like)

Last updated at Posted at 2023-10-26

この記事では、以下のライブラリを用いる。

import xarray as xr

xr.zeros_like()

xarrayの関数zeros_like()を使うと、任意のDataArrayの形状を引き継いだ新しいDataArrayを作ることができる。値は0で埋められる。

次のDataArrayを例として説明する。

array = xr.DataArray([[0,1,2],[3,4,5]], dims=['x','y'], coords={'x': [0,1], 'y': [0,1,2]})
array

image.png

使い方

xr.zeros_like(array)

image.png

似た機能を持つ関数

ones_like()1で埋める。

full_like()は指定した値で埋める。

公式ドキュメント

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?