金点网络-全网资源,一网打尽
  • 网站首页
    • 金点部落
    • 小游戏
    • OpenAPI
    • 设计资产导航
    • 升级会员
  • 技能学习
    • 体育运动
    • 办公教程
    • 口才演讲
    • 小吃技术
    • 建站教程
    • 摄影教程
    • 棋牌教程
    • 网赚教程
      • 爆粉引流
      • 自媒体
      • 贴吧引流
  • 网站源码
    • 商城/淘客/交易
    • 小说/漫画/阅读
    • 影视/音乐/视频
    • 微信/微商/微擎
    • 理财/金融/货币
    • 模板/主题/插件
  • 游戏源码
    • 精品网单
    • 端游源码
    • 手游源码
    • 页游源码
  • 素材资料
    • 电子文档
    • 综合资料
    • 考研资料
    • 设计素材
    • 音频讲座
      • 人文艺术
      • 名师讲座
      • 说书小说
  • 软件工具
    • Windows软件
    • MacOS软件
    • Android软件
  • 寄售资源
    • 游戏源码
    • 网站源码
    • 软件源码
  • 公益服
登录/注册
  • 专享大神特权
立即开通开通会员抄底价

Python数据分析(中英对照)·Building and Examining NumPy Arrays 构建和检查 NumPy 数组

作者 : jamin 本文共4773个字,预计阅读时间需要12分钟 发布时间: 2020-10-18 共1865人阅读

2.2.4: Building and Examining NumPy Arrays 构建和检查 NumPy 数组

NumPy provides a couple of ways to construct arrays with fixed,start, and end values, such that the other elements are uniformly spaced between them.
NumPy提供了两种方法来构造具有固定值、起始值和结束值的数组,以便其他元素在它们之间均匀分布。
To construct an array of 10 linearly spaced elements starting with 0 and ending with 100, we can use the NumPy linspace function.
要构造一个由10个线性间隔元素组成的数组,从0开始到100结束,我们可以使用NumPy linspace函数。
In this case, I’m going to type np.linspace.
在本例中,我将键入np.linspace。
The first argument is the starting point, which is 0.
第一个参数是起点,即0。
The second is the ending point, which will be included in the NumPy array that gets generated.
第二个是结束点,它将包含在生成的NumPy数组中。
And the final argument is the number of points I would like to have in my array.
最后一个参数是数组中的点数。
In this case, NumPy has created a linearly spaced array starting at 0 and ending at 100.
在本例中,NumPy创建了一个从0开始到100结束的线性间隔阵列。
Now, to construct an average of 10 logarithmically spaced elements between 10 and 100, we can do the following.
现在,要构造10个10到100之间的对数间隔元素的平均值,我们可以执行以下操作。
In this case we use the NumPy logspace command.
在本例中,我们使用NumPy logspace命令。
But now careful, the first argument that goes into logspace is going to be the log of the starting point.
但是现在要小心,进入日志空间的第一个参数将是起点的日志。
If you want the sequence to start at 10, the first argument has to be the log of 10 which is 1.
如果希望序列从10开始,则第一个参数必须是10的log,即1。
The second argument is the endpoint of the array, which is 100.
第二个参数是数组的端点,它是100。
And again, we need to put in the log of that, which is 2.
再一次,我们需要把它放到日志中,也就是2。
And the third argument as before, is the number of elements in our array.
和前面一样,第三个参数是数组中的元素数。
in this case, what NumPy has constructed is an array consisting of 10 elements where the first element is 10 and the last element is 100.
在本例中,NumPy构造了一个由10个元素组成的数组,其中第一个元素是10,最后一个元素是100。
All of the other elements are uniformly spaced between those two extreme points in the logarithmic space.
所有其他元素均匀分布在对数空间的两个端点之间。
To construct array of ten logarithmically spaced elements between numbers say 250 and 500, we first need to take the base 10 logarithm of the numbers, 250 and 500,and then feed those into the logspace function.
为了构造一个由10个对数间隔的元素组成的数组,比如250和500之间的数字,我们首先需要取250和500这两个数字的以10为底的对数,然后将它们输入对数空间函数。
So let’s try that out.
让我们试试看。
I’m going to start by typing np.logspace.
我将首先键入np.logspace。
And now we need to take the base 10 logarithm of the number 250.
现在我们需要取数字250的以10为底的对数。
To do that, I will type np.log10 and the number is 250.
为此,我将键入np.log10,数字是250。
For the second argument, I’m again going to be taking the logarithm base 10, in this case of the number 500, and I would like to have 10 elements in my array.
对于第二个参数,我将再次取以10为底的对数,在这个数字为500的情况下,我希望数组中有10个元素。
When I run this, the output is exactly what’s expected.
当我运行它时,输出正好是预期的。
Often we need to know the shape of an array or the number of elements in an array.
通常我们需要知道数组的形状或数组中元素的数量。
You can check the shape of an array using shape.
可以使用shape检查数组的形状。
I’m going to define the two dimensional array x,and to find out the shape of the array I can type x.shape.
我将定义二维数组x,为了找出数组的形状,我可以输入x.shape。
You can check the number of elements of an array with size.
可以使用大小检查数组的元素数。
So in this case, I can type x.size and I find out that I have six elements in my array.
在这个例子中,我可以输入x.size,我发现我的数组中有六个元素。
Notice that you don’t have parentheses following the shape or size in the above examples.
请注意,在上述示例中,形状或大小后面没有括号。
This is because shape and size are data attributes, not methods of the arrays.
这是因为形状和大小是数据属性,而不是数组的方法。
Sometimes we need to examine whether any or all elements of an array fulfill some logical condition.
有时我们需要检查数组的任何或所有元素是否满足某种逻辑条件。
Let’s generate a small one d array and check two things.
让我们生成一个小的一维数组并检查两件事。
First, if any of the entries are greater than 0.9,and second, if all of the entries are greater than or equal to 0.1.
首先,如果任何条目大于0.9,然后,如果所有条目都大于或等于0.1。
You may remember how we generated random numbers using the random module.
您可能还记得我们是如何使用随机模块生成随机数的。
NumPy has its own random module.
NumPy有自己的随机模块。
And in this case, we’re going to be generating 10 random numbers drawn from the standard uniform distribution, meaning from the interval from 0 to 1.
在这种情况下,我们将从标准均匀分布中生成10个随机数,也就是从0到1的区间。
I’m going to call this vector or array "x".
我将把这个向量或数组称为“x”。
And now we can use the np.any function to find out if any of the elements of x are greater than 0.9.
现在我们可以使用np.any函数来确定x的元素是否大于0.9。
And the answer is this case true.
答案是这种情况是正确的。
I can then use the np.all function to find out if all of the elements in the array are greater than or equal to 0.1.
然后我可以使用np.all函数来确定数组中的所有元素是否大于或等于0.1。
In this case, the answer is true.
在这种情况下,答案是正确的。
To make sense of these results, we can print out the content of x.
为了理解这些结果,我们可以打印出x的内容。
By looking at the second element on the second row, which is to 0.9216 and so on, we have an element which is greater than 0.9.
通过查看第二行的第二个元素,即0.9216,依此类推,我们得到了一个大于0.9的元素。
Therefore, we have at least one of those elements,and therefore np.any returns true to us.
因此,我们至少有一个元素,因此np.any返回给我们。
If you look at all of the elements in our vector x, you see that all of them are indeed greater than 0.1.
如果你看向量x中的所有元素,你会发现它们都大于0.1。
And that’s why np.all also returns true.
这就是为什么np.all也返回true。
Note that the output is either true or false for the whole array.
请注意,整个数组的输出为true或false。
Either there is or is not one or more entries that are greater than 0.9.
存在或不存在一个或多个大于0.9的条目。
Also, either all entries are greater or equal to 0.1 or they are not.
此外,所有条目要么大于或等于0.1,要么不大于或等于0.1。
This is why the output is just a single true or false.
这就是为什么输出只有一个true或false。

Python 数据分析
本站所提供的部分资源来自于网络,版权争议与本站无关,版权归原创者所有!仅限用于学习和研究目的,不得将上述内容资源用于商业或者非法用途,否则,一切后果请用户自负。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源。如果上述内容资对您的版权或者利益造成损害,请提供相应的资质证明,我们将于3个工作日内予以删除。本站不保证所提供下载的资源的准确性、安全性和完整性,源码仅供下载学习之用!如用于商业或者非法用途,与本站无关,一切后果请用户自负!本站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。如有侵权、不妥之处,请联系站长以便删除!
金点网络-全网资源,一网打尽 » Python数据分析(中英对照)·Building and Examining NumPy Arrays 构建和检查 NumPy 数组

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
是否提供免费更新服务?
持续更新,永久免费
是否经过安全检测?
安全无毒,放心食用
jamin

jamin 大神

下一篇
网络协议-组播介绍

相关推荐

Python数据分析(中英对照)·Strings 字符串

Python数据分析(中英对照)·Strings 字符串

Python数据分析(中英对照)·Dictionaries 字典

Python数据分析(中英对照)·Dictionaries 字典

Python数据分析(中英对照)·Examples Involving Randomness 涉及随机性的例子

Python数据分析(中英对照)·Examples Involving Randomness 涉及随机性的例子

Python数据分析(中英对照)·Modules and Methods 模块和方法

Python数据分析(中英对照)·Modules and Methods 模块和方法

Python数据分析(中英对照)·Objects 对象

Python数据分析(中英对照)·Objects 对象

标签云
Android Atom ExecutorService ForkJoin GM GM后台 GM授权后台 H5 Java Javascript Linux手工服务端 pipbestcom Python ReentrantLock synchronized ThreadLocal volatile Win一键即玩服务端 一键端 传奇 写作 创业 单机 后台 商业端 外网 安卓 安卓苹果双端 工具 手工端 手游 搭建教程 教程 数据分析 文案 游戏源码 端游 经典 网单 职场 自媒体 视频教程 详细搭建教程 运营后台 页游

近期文章

  • 回合手游【逍遥西游之繁华西游】最新整理单机一键既玩镜像服务端_Linux手工端_GM后台_教程
  • 最新整理精品回合制手游【天书奇谈3D混沌完整版】VM一键单机版_linux手工外网端_隐盟视频教程_授权GM后台_双端
  • 典藏修真页游【诸仙列传OL】最新整理Win系服务端_GM工具_详细外网搭建教程
  • MT3换皮MH【浮生若梦尊享挂机修复版】最新整理单机一键即玩镜像端_Linux手工服务端_安卓苹果双端_GM后台_详细搭建教程
  • 大话回合手游【最新引擎之缥缈西游渡劫版】最新整理Linux手工服务端_安卓苹果双端_管理后台_CDK后台_详细搭建教程_视频教程

分类

  • | wordpress插件 |
  • | wordpress模板 |
  • | 其它模板 |
  • | 帝国模板 |
  • | 织梦插件 |
  • | 织梦模板 |
  • A5源码
  • Android软件
  • APP引流
  • E语言
  • H5
  • LUA
  • QQ营销
  • SEO推广
  • Windows软件
  • 体育运动
  • 信息数据
  • 创业专题
  • 办公教程
  • 口才演讲
  • 名师讲座
  • 商城/淘客/交易
  • 小吃技术
  • 小说/漫画/阅读
  • 建站教程
  • 引流脚本
  • 影视/音乐/视频
  • 影视资源
  • 微信/微商/微擎
  • 微信小程序
  • 微信营销
  • 微擎模块
  • 手游源码
  • 技能学习
  • 抖音课程
  • 摄影教程
  • 棋牌教程
  • 模板/主题/插件
  • 游戏源码
  • 爆粉引流
  • 理财/金融/货币
  • 生活老师
  • 电商客
  • 电子文档
  • 电脑教程
  • 社群营销
  • 站长工具
  • 精品网单
  • 系统工具
  • 素材资料
  • 综合资料
  • 编程经验
  • 网站源码
  • 网络安全
  • 网赚教程
  • 网赚源码
  • 考研资料
  • 脚本/AI/智能
  • 自媒体
  • 英语学习
  • 营销软件
  • 设计素材
  • 说书小说
  • 贴吧引流
  • 软件工具
  • 软文营销
  • 逆向软件
  • 音频讲座
  • 页游源码

提供最优质的资源集合

立即加入 友好社区
金点网络-全网资源,一网打尽

新一代全网资源综合门户网(www.pipbest.com-金点网络)专注服务于互联网,提供各类最新最全的免费源码下载(PHP、ASP、JSP、.NET),更提供免费工具,免费源码下载,软件下载,素材下载,赚钱教程下载,交流论坛等网站运营相关的一切内容,为网友搜罗最有价值的网站源码下载与技术教程等服务!

服务目录
  • 金点OpenAPI
  • 金点云
  • 金点支付
友情链接
  • 数媒派
  • 国家电网
快速搜索

本站由Nice强力驱动

声明: 本站部分内容属于原创转载请注明出处 如有侵权行为请严格参照本站【版权声明】与我们联系,我们将在48小时内容进行处理!

本站部分内容属于原创转载请注明出处 如有侵权行为请严格参照本站【版权声明】与我们联系,我们将在48小时内容进行处理!
© 2016-2023 PipBest.Com - 金点网络 & 金点部落. All rights reserved 京ICP备2022005359号-1
  • 关注有礼
  • 签到
  • 客服
    官方QQ群 常见问题 FAQ

    在线客服

    点我联系

    直接说出您的需求!
    切记!带上资源连接与问题!

    工作时间: 9:30-21:30

  • 暗黑
    模式
  • 全屏
  • 投稿
    赚钱
  • 首页

  • 签到

  • 切换

  • 客服

金点网络-全网资源,一网打尽
  • 登录
  • 注册
or
or
忘记密码?
金点网络-全网资源,一网打尽
  • 网站首页 ►
    • 金点部落
    • 小游戏
    • OpenAPI
    • 设计资产导航
    • 升级会员
  • 技能学习 ►
    • 体育运动
    • 办公教程
    • 口才演讲
    • 小吃技术
    • 建站教程
    • 摄影教程
    • 棋牌教程
    • 网赚教程 ►
      • 爆粉引流
      • 自媒体
      • 贴吧引流
  • 网站源码 ►
    • 商城/淘客/交易
    • 小说/漫画/阅读
    • 影视/音乐/视频
    • 微信/微商/微擎
    • 理财/金融/货币
    • 模板/主题/插件
  • 游戏源码 ►
    • 精品网单
    • 端游源码
    • 手游源码
    • 页游源码
  • 素材资料 ►
    • 电子文档
    • 综合资料
    • 考研资料
    • 设计素材
    • 音频讲座 ►
      • 人文艺术
      • 名师讲座
      • 说书小说
  • 软件工具 ►
    • Windows软件
    • MacOS软件
    • Android软件
  • 寄售资源
    ►
    • 游戏源码
    • 网站源码
    • 软件源码
  • 公益服
×
u3** 刚刚下载了 爆款吸金文案训练

    全网资源·一网打尽

  • 金点出品,必属精品!
  • 发布原创内容,获取高额提成!
  • 我们与你共创美好数字生态!
  • 无特殊说明密码默认:pipbest.com