python xlwing関数 指定した標準偏差と中央値で、任意の行・列数のデータを作成する mshmura


python の関数

myproject.py
import xlwings as xw
import numpy as np

@xw.func
@xw.ret(expand = "table")
def randstd(mean, std, rows, columns):
    return np.random.normal(mean, std, (int(rows), int(columns)))

excel設定

1.上部の 「UDF MODULEs:」 のところに上記のpythonファイル名(myproject)を入れる。
(※myprojectはexcelファイルと同じフォルダに入っていると仮定)

適当なセルに、任意の中央値、標準偏差、テーブルの行数、列数を書き込む。

下記のように関数を入れる。

結果

以上。