Skip to Content
利用 Python 进行数据分析:原书第 3 版
book

利用 Python 进行数据分析:原书第 3 版

by Wes McKinney
November 2023
Intermediate to advanced
512 pages
11h 53m
Chinese
China Machine Press
Content preview from 利用 Python 进行数据分析:原书第 3 版
468
|
附录
A
为了得到各数据点所属区间的编号(其中
1
表示分箱 [0,100),我们可以直接使用
searchsorted
再结合
pandas
groupby 方法,就可以轻松地对原数据集进行分箱:
A.7
使用
Numba
编写快速
NumPy
函数
Numba
http://numba.pydata.org
)是一个开源项目,它可以利用
CPU
GPU
或其他硬件
NumPy
类型数据创建快速函数。它使用了
LLVM
项目(
http://llvm.org/
),
Python
代码编译为机器代码。
为了介绍
Numba
,先考虑一个纯
Python
函数,它使用 for 循环计算表达式 (x
-
y).
mean()
这个函数很慢:
高阶
NumPy
|
469
NumPy
的版本要比它快
100
倍。使用 numba.jit 函数,我们可以将这个函数编译为
Numba
函数:
也可以写成装饰器的形式:
这个函数要比向量化的
NumPy
更快:
Numba
不能编译所有的纯
Python
代码,但它支持
Python
中的一类重要代码,即最有用
的数值算法。
Numba
是一个功能强大的库,支持多种硬件、编译模式和用户扩展。它还可以编译
NumPy Python API
的一个实质性子集,而不使用 for 循环。
Numba
也可以识别可以
编译为机器编码的结构体 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Effective Python 第3版 ―Pythonプログラムを改良する125項目

Effective Python 第3版 ―Pythonプログラムを改良する125項目

Brett Slatkin, 鈴木 駿

Publisher Resources

ISBN: 9787111726722