当前位置:网站首页>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

边栏推荐
- 时间序列数据的预处理方法总结
- COPU陆首群教授应邀在开放原子全球开源峰会上做主旨演讲
- Android必备的面试技能(含面试题和学习资料)
- 16.偏差、方差、正则化、学习曲线对模型的影响
- CDN mode uses vant components, and components cannot be called after they are introduced
- 第二轮1000个Okaleido Tiger,再次登录Binance NFT 1小时售罄
- 华为发布HarmonyOS 3.0,向“万物互联”再迈一步
- 伦敦金即时行情带来什么机会?
- Isolation level of MySQL, possible problems (dirty reading, unrepeatable reading, phantom reading) and their solutions
- Still writing a lot of if to judge? A rule executor kills all if judgments in the project
猜你喜欢

2022DASCTF7月赋能赛(复现)
![Error reporting: the network preview shows {xxx:['this field is required']}](/img/96/b0a6c01543fcbcc6d3262b3797fae2.jpg)
Error reporting: the network preview shows {xxx:['this field is required']}

Application and principle of distributed current limiting redistribution rratelimiter

将行内元素转换为块元素的方法

How to solve the problems of MQ message loss, duplication and backlog?

Outlier detection and open set identification (1)

PTA (daily question) 7-75 how many people in a school

Huawei releases harmonyos 3.0, taking another step towards "Internet of all things"

从零开始实现lmax-Disruptor队列(六)Disruptor 解决伪共享、消费者优雅停止实现原理解析

第二轮1000个Okaleido Tiger,再次登录Binance NFT 1小时售罄
随机推荐
How to solve the problems of MQ message loss, duplication and backlog?
管理区解耦架构见过吗?能帮客户搞定大难题的
【开发教程11】疯壳·开源蓝牙心率防水运动手环-整机功能代码讲解
伦敦金即时行情带来什么机会?
Brief introduction to compressed sensing
[development tutorial 11] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - explanation of the function code of the whole machine
直流无刷电机控制器(换电机霍尔收费多少)
requestVideoFrameCallback() 简单实例
Android必备的面试技能(含面试题和学习资料)
PTA (daily question) 7-71 character trapezoid
Yield Guild Games:这一年的总结与未来展望
从零开始实现lmax-Disruptor队列(六)Disruptor 解决伪共享、消费者优雅停止实现原理解析
Matlab02: structured programming and function definition "suggestions collection"
PTA (daily question) 7-74 yesterday
关于ThreadPool的一些注意事项
Xinchi technology released the latest flagship product of G9 series, equipped with six A55 cores with 1.8GHz dominant frequency
PTA (daily question) 7-70 diamond
Soft test --- database (4) SQL statement
MATLAB02:结构化编程和函数定义「建议收藏」
Common sparse basis and matlab code for compressed sensing