首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

Python数据分析(中英对照)·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 defin

02

试用GO开发pyhton编译器:字节码基础

掌握一门编程语言最好的办法或许是将它的编译器设计出来。毫无疑问那些开发Python编译器的人应该是世界上对Python了解最深刻的人群之一。我用python开发过不少程序,但是每次反思或复盘的时候总是感觉对Python的认知还不到位,由此也看了很多讲Python的书,但看的时候感觉好像懂了,但过了一段时间后又忘了,也就是说单纯看书很难将某一项技术完全内化。当然技能的掌握必然要从实践中来,但是我发现在使用Python开发程序时,我总是使用它的一部分功能就够了,或者说居于我的思维模式限制,我在使用python开发时总是落入一个套路,这使得我只能掌握python技术的冰山一角,就如同井底之蛙一样只了解一小块内容,为了能够打破认知局限,让我自己能更全面的对python的设计原理有更深入的了解,我打算尝试做一个能运行的python编译器。

02

C++中的不规则二维数组

最近刚学习C++的一些编程技巧,对于一些相对比较陌生的问题,只能采取一些简单粗暴的方案来实现。就比如说,我们可以在Python中定义一个[[0,0,0],[1,2],[1,1,1],[3]]这样的不规则的二维数组(list)。那么如果我们想在C++中实现一个类似的数据结构,应该怎么去设计呢?更具体一点的问题,当我们给C++输入一个固定长度的数组,比如Shape为(4,3),然后再给出一个Shape为(4,)的有效索引数组,保存的是第二个维度中数据的有效长度(这里有个要求是输入的有效位数处于固定长度数组的末尾,因为我们一般去更新数组时也是从末尾处push_back进去)。最后用一个数据结构保存这个不规则的二维数组,并且可以正常索引和打印。

01
领券