1
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 5 years have passed since last update.

scipyでspecialがない??

Last updated at Posted at 2019-12-25

概要

$_4C_2$ をpythonで求めたい。
scipyというライブラリのscipy.special.combを使うと簡単にできそう。

エラー

以下のように書くと

import scipy
print(scipy.special.comb(4, 2))

エラー

AttributeError: module 'scipy' has no attribute 'special'

解決策

以下のように書くとOK

from scipy.special import comb
print(comb(4, 2))

実行結果

6.0

以下も可

from scipy import special
print(special.comb(4, 2))

まとめ

import scipy
ではなく
from scipy.special import comb or
from scipy import special

1
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
1
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?