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

Python数据分析(中英对照)·Introduction to NumPy Arrays NumPy 数组简介

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

2.2.1: Introduction to NumPy Arrays NumPy 数组简介

NumPy is a Python module designed for scientific computation.
NumPy是为科学计算而设计的Python模块。
NumPy has several very useful features.
NumPy有几个非常有用的特性。
Here are some examples.
这里有一些例子。
NumPy arrays are n-dimensional array objects and they are a core component of scientific and numerical computation in Python.
NumPy数组是n维数组对象,是Python中科学和数值计算的核心组件。
NumPy also provides tools for integrating your code with existing C,C++, and Fortran code.
NUMPY还提供了将代码与现有C、C++和FORTRAN代码集成的工具。
NumPy also provides many useful tools to help you perform linear algebra, generate random numbers, and much, much more.
NumPy还提供了许多有用的工具来帮助您执行线性代数、生成随机数等等。
You can learn more about NumPy from the website numpy.org.
您可以从网站NumPy.org了解更多关于NumPy的信息。
NumPy arrays are an additional data type provided by NumPy,and they are used for representing vectors and matrices.
NumPy数组是NumPy提供的附加数据类型,用于表示向量和矩阵。
Unlike dynamically growing Python lists, NumPy arrays have a size that is fixed when they are constructed.
与动态增长的Python列表不同,NumPy数组的大小在构造时是固定的。
Elements of NumPy arrays are also all of the same data type leading to more efficient and simpler code than using Python’s standard data types.
NumPy数组的元素也都是相同的数据类型,这使得代码比使用Python的标准数据类型更高效、更简单。
By default, the elements are floating point numbers.
默认情况下,元素是浮点数。
Let’s start by constructing an empty vector and an empty matrix.
让我们先构造一个空向量和一个空矩阵。
By the way, don’t worry if you’re not that familiar with matrices.
顺便说一句,如果你对矩阵不太熟悉,别担心。
You can just think of them as two-dimensional tables.
你可以把它们想象成二维表格。
We will always use the following way to import NumPy into Python– import numpy as np.
我们将始终使用以下方法将NumPy导入Python——将NumPy作为np导入。
This is the import we will always use.
这是我们将始终使用的导入。
We’re first going to define our first zero vector using the numpy np.zeros function.
我们首先要用numpy np.zeros函数定义我们的第一个零向量。
In this case, if we would like to have five elements in the vector,we can just type np.zeros and place the number 5 inside the parentheses.
在这种情况下,如果我们想在向量中有五个元素,我们可以只键入np.zero并将数字5放在括号内。
We can define a two-dimensional array– let’s called that zero_matrix– in the following way:
我们可以用以下方式定义一个二维数组——我们称之为零矩阵:
We, again, provide only one argument to NumPy.
我们再次向NumPy提供了一个参数。
In this case, it has to be a tuple.
在这种情况下,它必须是一个元组。
A tuple specifies two things.
元组指定两件事。
The first argument is the number of rows in the table and the second argument is the number of columns in our table.
第一个参数是表中的行数,第二个参数是表中的列数。
So if you would like to create a five by three table,we type np.zeros, two parentheses, 5 comma 3, and two closing parentheses.
如果你想创建一个五乘三的表,我们输入np.0,两个括号,5个逗号3和两个右括号。
Both the zero_vector and the zero_matrix will contain only zeroes as their elements.
zero_向量和zero_矩阵将只包含零作为其元素。
We can see it as we type zero_vector, and similarly if we type zero_matrix.
当我们输入zero_向量时,我们可以看到它,同样,如果我们输入zero_矩阵。
You can also construct arrays of ones using the np.ones function,and its index is identical to the syntax of the zero’s function.
还可以使用np.ones函数构造一个数组,其索引与zero函数的语法相同。
To create an empty array, you can use the np.empty function, which allocates the requested space for the array, but does not initialize it,meaning that the content could be anything, whatever happens to be in the computer’s memory at the location where the array is set up.
要创建空数组,您可以使用np.empty函数,该函数为数组分配请求的空间,但不初始化它,这意味着内容可以是任何内容,不管在设置数组的位置计算机内存中发生了什么。
If you are dealing with a very large array and you know for sure that you will be updating each element of the array,this could save you some computation time because Python doesn’t need to initialize the array.
如果您处理的是一个非常大的数组,并且您肯定会更新数组的每个元素,那么这可以节省一些计算时间,因为Python不需要初始化数组。
However, you should use this function with care and if you’re new to NumPy, it’s probably best to avoid it at first.
但是,您应该小心地使用此函数,如果您是NumPy新手,可能最好首先避免使用它。
We can also construct NumPy arrays using specified values, in which case,we use the np.array function, and the input argument to the function is a sequence of numbers, typically a list of numbers.
我们还可以使用指定的值构造NumPy数组,在这种情况下,我们使用np.array函数,该函数的输入参数是一个数字序列,通常是一个数字列表。
In what follows, we assume that lower case variables are vectors or one-dimensional arrays and upper case variables are matrices, or two-dimensional arrays.
在下面的内容中,我们假设小写变量是向量或一维数组,而大写变量是矩阵或二维数组。
To practice creating NumPy arrays, let’s create two, short, one-dimensional arrays.
为了练习创建NumPy数组,让我们创建两个短的一维数组。
Our first array is going to be called x, and it consists of the numbers 1, 2, and 3.
我们的第一个数组将被称为x,它由数字1、2和3组成。
Our second NumPy array is going to be called y,and that’s going to consist of the numbers 2, 4, and 6.
我们的第二个NumPy数组将被称为y,它将由数字2、4和6组成。
When you construct a two-dimensional NumPy array,you specify the elements of each row as a list and you can then define the entire table as a list that contains at its elements each of the lists of the row elements you’ve defined.
构造二维NumPy数组时,将每行的元素指定为列表,然后可以将整个表定义为一个列表,该列表在其元素处包含已定义的行元素列表的每个元素。
Let’s work through a simple example.
让我们看一个简单的例子。
Let’s define the first row as consisting of numbers 1 and 3.
让我们将第一行定义为由数字1和3组成。
Then we can define the second row as consisting of the numbers 5 and 9.
然后我们可以将第二行定义为由数字5和9组成。
So here we have two lists that are separated by a comma.
这里我们有两个列表,用逗号分隔。
And we will embed these two lists inside yet another list,and now we have our nested list object.
我们将把这两个列表嵌入到另一个列表中,现在我们有了嵌套的列表对象。
To turn this into a NumPy array, we type np.array and the nested list object goes inside the parentheses.
要将其转换为NumPy数组,我们键入np.array,嵌套的list对象放在括号内。
Finally, sometimes you want to turn the table sideways.
最后,有时你想把桌子转向一边。
This is called taking the transpose of a matrix, which means that the first row becomes the first column,the second row becomes the second column, and so on.
这被称为对矩阵进行转置,这意味着第一行成为第一列,第二行成为第二列,依此类推。
Notice that another identical way to state this is to say that the first column becomes the first row.
请注意,另一种相同的方式是将第一列变为第一行。
The second column becomes the second row, and so on.
第二列成为第二行,依此类推。
We can transpose a two-dimensional array using the transpose method.
我们可以使用转置方法对二维数组进行转置。
If we go back to the array that we had here– let’s call this A.
如果我们回到这里的数组,我们称之为A。
We can use now the transpose method to flip the array around.
我们现在可以使用转置方法来翻转数组。

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

常见问题FAQ

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

jamin 大神

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

相关推荐

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

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

Python数据分析(中英对照)·Slicing NumPy Arrays 切片 NumPy 数组

Python数据分析(中英对照)·Slicing NumPy Arrays 切片 NumPy 数组

Python数据分析(中英对照)·Sequences 序列

Python数据分析(中英对照)·Sequences 序列

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

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

Python数据分析(中英对照)·Tuples 元组

Python数据分析(中英对照)·Tuples 元组

标签云
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