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

边栏推荐
- Requestvideoframecallback() simple instance
- Shell programming specifications and variables
- 保护性拷贝&无状态
- Flash and seven cattle cloud upload pictures
- 数仓搭建——ADS层
- Common sparse basis and matlab code for compressed sensing
- How to learn R language
- Anti shake and throttling
- Asynchronous mode worker thread
- armeabi-v7a架构(sv7a)
猜你喜欢

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

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

2022dasctfjuly empowerment competition (reappearance)

Data warehouse construction - ads floor

靠云业务独撑收入增长大梁,微软仍然被高估?

Router view cannot be rendered (a very low-level error)

15. Model evaluation and selection

15.模型评估和选择问题

Requestvideoframecallback() simple instance

17. Design of machine learning system
随机推荐
The 30th day of question brushing
MySQL sub database and sub table and its smooth expansion scheme
【网络安全】通过iptables和ipset完成服务器防火墙黑名单和白名单功能
从零开始实现lmax-Disruptor队列(六)Disruptor 解决伪共享、消费者优雅停止实现原理解析
NPM run serve stuck at 40%
Meeting notification & meeting feedback & feedback details function of meeting OA project
Basic knowledge of PHP language (super detailed)
伦敦金即时行情带来什么机会?
Error reporting: Rong Lianyun sends SMS verification code message 500
MySQL的隔离级别、可能出现的问题(脏读、不可重复读、幻读)及其解决方法
Flyway's quick start tutorial
【MySQL 8】Generated Invisible Primary Keys(GIPK)
异步模式之工作线程
PTA (daily question) 7-74 yesterday
ZABBIX deployment and monitoring
Solutions such as failed plug-in installation and slow speed of linking remote server under vscode
[development tutorial 11] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - explanation of the function code of the whole machine
selenium对接代理与seleniumwire访问开发者工具NetWork
[ESN] learning echo state network
追踪伦敦银实时行情的方法