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 版
高阶
NumPy
|
451
A.2.5
花式索引的等价方法:
take
put
4
章讲过,获取和设置数组子集的办法之一是通过整数数组使用花式索引:
对于在单个轴向上进行选取这种特殊情况,
ndarray
还有其他方法:
要在其他轴上使用 take,只需传入关键字 axis 即可:
put 不接收参数 axis,它只会在数组的扁平化(一维,
C
顺序)版本上进行索引。因此,
在需要用其他轴向的索引设置元素时,最好还是使用花式索引。
A.3
广播
广播机制指的是不同形状数组之间的算术运算执行方式。这是一种非常强大的功能,但
452
|
附录
A
也容易令人误解,即使是经验丰富的老手也是如此。标量值和数组的运算是最简单的广
播示例:
在这个乘法运算中,标量值
4
被广播到了其他所有元素上。
看一个例子,我们可以通过减去列平均值的方式,降低数组中每一列的数值。对于这种
情况,只能通过减去包含各列平均值的数组来实现:
A-4
形象地展示了该操作过程。用广播的方式对行减去均值时需要特别留心。幸运的
是,只要遵循一定的规则,低维度的值是可以被广播到数组的任意维度的(比如对二维
数组各列减去行平均值)。
于是就得到了广播机制。
广播机制
如果两个数组的后缘维度(即从末尾开始算起的维度)的轴长度相符或其中一方
的长度为 1,则这两个数组是广播兼容的。广播会在缺失维度或长度为 ...
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