numpy遍历每行操作_每个数据科学家都应该知道的20 numpy操作

numpy遍历每行操作

Everything about data science starts with data and it comes in various formats. Numbers, images, texts, x-rays, sound, and video recordings are just some examples of data sources. Whatever the format data comes in, it needs to be converted to an array of numbers to be analyzed. Hence, it is crucial to effectively store and modify arrays of numbers in data science.

有关数据科学的所有内容都始于数据,并且格式多种多样。 数字,图像,文本,X射线,声音和视频记录只是数据源的一些示例。 无论输入哪种格式的数据,都需要将其转换为要分析的数字数组。 因此,在数据科学中有效地存储和修改数字数组至关重要。

NumPy (Numerical Python) is a scientific computing package that provides numerous ways to create and operate on arrays of numbers. It forms the basis of many widely used Python libraries related to data science such as Pandas and Matplotlib.

NumPy (数字Python)是一种科学计算程序包,它提供了许多创建和处理数字数组的方法。 它构成了许多与数据科学相关的广泛使用的Python库的基础,例如Pandas和Matplotlib。

In this post, I will go over 20 commonly used operations on NumPy arrays. These operations can be grouped under 4 main categories:

在本文中,我将介绍NumPy数组的20多个常用操作。 这些操作可以分为4个主要类别:

  • Creating arrays

    创建数组
  • Manipulating arrays

    操纵数组
  • Combining arrays

    合并数组
  • Linear algebra with arrays

    带数组的线性代数

We first need to import NumPy:

我们首先需要导入NumPy:

import numpy as np

创建数组 (Creating arrays)

  1. Random integers in a specific range

    特定范围内的随机整数

Image for post

The first parameter determines the upper bound of the range. The lower bound is 0 by default but we can also specify it. The size parameter is used to specify the size, as expected.

第一个参数确定范围的上限。 下限默认为0,但我们也可以指定它。 size参数用于指定大小,如预期的那样。

Image for post

We created a 3x2 array of integers between 2 and 10.

我们创建了一个3x2的2到10整数数组。

2. Random floats between 0 and 1

2.随机浮点数介于0和1之间

Image for post

A 1-dimensional array of floats between 0 and 1. It is useful to create random noise data.

浮点数的1维数组,介于0和1之间。创建随机噪声数据非常有用。

3. Sample from a standard normal distribution

3.来自标准正态分布的样本

Np.random.randn() is used to create a sample from a standard normal distribution (i.e. zero mean and unit variance).

Np.random.randn()用于根据标准正态分布(即零均值和单位方差)创建样本。

Image for post
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值