当前位置:网站首页>Five interesting magic commands in jupyter notebook
Five interesting magic commands in jupyter notebook
2022-07-29 00:50:00 【I love Python data mining】
many As we all know ,Jupyter notebook It's an interactive Python shell, That is to say IPython The packaged version of , It is very suitable for data analysis and machine learning .
Jupyter notebook There are many practical and little-known functions in , Can achieve interesting operations , Like to remember to collect 、 Focus on 、 give the thumbs-up .
Unlock more tips , At the end of the article, add groups to discuss .
This time 5 A simple example .
1、 Script code is written to local file
%%file Method can write script code locally Py file .
%%file E:\hello.py
def func_inside_script(x, y):
return x + y
print('Hello World')

2、 perform Py file
stay notebook Can be directly executed Py file , adopt %run Method to implement .
%run hello.py

3、 Monitor code runtime
Maybe your code needs precise time control , that %timeit Methods can help you .
%timeit [x**2 for x in range(100)]

4、 Use the system command line
stay windows in , To use the command line, you need to open cmd window , If you use notebook, You can use the ! Method to easily execute command line code .
# New folder
my_dir = 'new_dir'
!mkdir $my_dir
5、 Fast debug
bug It's a headache , stay notebook Can be easily carried out debug, Use %debug Command is enough .
def some_func():
var = 'hello world'
for i in range(5):
print(i)
i / 0
return 'finished'
%debug
some_func()

Jupyter notebook There are also many interesting magic commands , If you are interested, you can explore more .
Recommended articles
Li Hongyi 《 machine learning 》 Mandarin Program (2022) coming
Some people made Mr. Wu Enda's machine learning and in-depth learning into a Chinese version
So elegant ,4 paragraph Python Automatic data analysis artifact is really fragrant
Technical communication
Welcome to reprint 、 Collection 、 Gain some praise and support ! data 、 The code can be obtained from me

At present, a technical exchange group has been opened , Group friends have exceeded 2000 people , The best way to add notes is : source + Interest direction , Easy to find like-minded friends
- The way ①、 Send the following picture to wechat , Long press recognition , The background to reply : Add group ;
- The way ②、 Add microsignals :dkl88191, remarks : come from CSDN
- The way ③、 WeChat search official account :Python Learning and data mining , The background to reply : Add group

边栏推荐
- Rk3399 9.0 driver add powser button
- AQS原理
- I was asked several questions about string in the interview. Can you answer them?
- 第二轮1000个Okaleido Tiger,再次登录Binance NFT 1小时售罄
- execute immediate 简单示例合集(DML)
- Breadth first search (BFS) and its matlab code
- 保护性拷贝&无状态
- Still writing a lot of if to judge? A rule executor kills all if judgments in the project
- Educational Codeforces Round 132 (Rated for Div. 2)【A~C】
- Huawei releases harmonyos 3.0, taking another step towards "Internet of all things"
猜你喜欢

Outlier detection and open set identification (1)

16. Influence of deviation, variance, regularization and learning curve on the model

PTA (daily question) 7-70 diamond

【esn】 学习回声状态网络

PTA (daily question) 7-72 calculate the cumulative sum

selenium对接代理与seleniumwire访问开发者工具NetWork

zabbix部署及监控

NPM run serve stuck at 40%

2022dasctfjuly empowerment competition (reappearance)
![[development tutorial 11] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - explanation of the function code of the whole machine](/img/a1/9a69e5d123a8a11504da251bd1bcfc.png)
[development tutorial 11] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - explanation of the function code of the whole machine
随机推荐
最长上升子序列
[ESN] learning echo state network
Soft test --- database (4) SQL statement
NPM run serve stuck at 40%
PTA (one question per day) 7-76 ratio
保护性拷贝&无状态
Oracle实例无法启动的问题如何解决
直流无刷电机控制器(换电机霍尔收费多少)
Rk3399 9.0 driver add powser button
【开发教程11】疯壳·开源蓝牙心率防水运动手环-整机功能代码讲解
Data warehouse construction - ads floor
Shell programming specifications and variables
Armeabi-v7a architecture (sv7a)
Minimum dominating set (MDS) and its matlab code
管理区解耦架构见过吗?能帮客户搞定大难题的
Execute immediate simple sample set (DML)
SurfaceControl和SurfaceFlinger通信
芯驰科技发布G9系列最新旗舰产品,配备6个1.8Ghz主频的A55核心
Calculate properties and listeners
伦敦金即时行情带来什么机会?