美文网首页
NumPy创建的几种方式

NumPy创建的几种方式

作者: 落泪无痕_ | 来源:发表于2019-01-17 17:03 被阅读0次

    import numpy as np

1. 列表赋值:

    a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

2. 自定义结构化类型

    student_type = np.dtype([('name', 'U20'), ('sex', 'U1'), ('age', 'i1'), ('marks', 'f4')])

    students = np.array([('张三', '男', 18, 87.6), ('李四', '女', 19, 100),  ('王五', '男', 28, 85.5)],         dtype=student_type)

3. st_end+步长

    x = np.arange(10, 20, 3).reshape(2,2)

4. 均匀散列

    x = np.linspace(10,20,5)

5. 对数形式

    a = np.logspace(1,10,num = 10, base = 2)

6. 范围创建

    myarray=np.arange(20)

相关文章

  • NumPy创建的几种方式

    import numpy as np 1. 列表赋值: a = np.array([[1, 2, 3], [4...

  • 一、ndarrary 的创建

    ndarrary 的创建¶ import numpy as np 数组的创建方式: (1)arra...

  • Python数据科学库-小测验

    考察内容包括numpy、pandas、matplotlib这3个库的内容 1、请写出numpy中创建数组的方式 答...

  • JavaScript函数_01创建函数的几种方式

    01创建函数的几种方式 创建函数的几种方式 01 函数声明02 函数表达式03 new Function() ne...

  • 02 numpy 科学计算库

    numpy 几种属性 ndim: 维度 shape: 行数和列数 size: 元素个数 打印 numpy 的几种属...

  • Function构造函数

    函数创建的几种方式 函数声明 字面量的方式创建 使用new Function的形式创建 函数创建代码示例 Func...

  • ES入门2-CRUD

    Index API Index API提供了几种创建Index方式。简单方式创建index 在创建索引的时候指定分...

  • 创建线程几种方式

    1、继承Thread类 2、实现Runnable接口 推荐:可实现多个接口,而只能继承一个类。 3、应用程序可以使...

  • 创建对象的几种方式

    字面量方式和Object构造函数方式创建对象 优点: 方便缺点: 当需要创建很对对象的时候,会有很多重复的代码 工...

  • 创建对象的几种方式

    第一种:对象字面量的方式 第二种:创建Object实例: 第三种:数构造函数无参数构造函数 带参数的构造函数 第四...

网友评论

      本文标题:NumPy创建的几种方式

      本文链接:https://www.haomeiwen.com/subject/hvgidqtx.html