Skip to Content
Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
book

Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

by Jake VanderPlas, 菊池 彰
May 2018
Intermediate to advanced
556 pages
13h 21m
Japanese
O'Reilly Japan, Inc.
Content preview from Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
12
1
章 
IPython
Python
より優れた
Python
これら
Magic
コマンドは、この後で取り上げるものも含めて標準の
Python
インタープリタでは
実行が困難であるか不可能な機能を提供します。
1.4.2
 外部コードの実行:
%run
より広範なコードを開発し始めると、対話的な探索のための
IPython
と再利用したいコードを書
くためのテキストエディタの両方を使うことになるでしょう。このコードを新しいウィンドウで実
行するのではなく、
IPython
のセッション内で実行できれば便利です。これは
%run
Magic
コマンド
で実現できます。
例えば、次の内容の
myscript.py
を作成したとしましょう。
#-------------------------------------
# file: myscript.py
def square(x):
"""square a number"""
return x ** 2
for N in range(1,
4):
print(N, "squared is", square(N))
これを
IPyton
のセッションから実行できます。
In [6]: %run myscript.py
1 squared is 1
2 squared is 4
3 squared is 9
このスクリプトを実行した後、そのスクリプト内で定義されている関数はすべて、
IPython
セッ
ションで使用できます。
In [7]: square(5)
Out[7]: 25
コードの実行方法を微
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Jake VanderPlas, 菊池 彰
初めてのGraphQL ―Webサービスを作って学ぶ新世代API

初めてのGraphQL ―Webサービスを作って学ぶ新世代API

Eve Porcello, Alex Banks, 尾崎 沙耶, あんどうやすし

Publisher Resources

ISBN: 9784873118413Other