avatar

刘刚刚的blog

采菊东篱下,悠然见南山🦥

  • 首页
  • python
  • 大模型应用
  • 软件/工具导航页
  • 关于
Home 02-numpy数组对象的基本属性
文章

02-numpy数组对象的基本属性

Posted 2020-12-19 Updated 2024-12- 17
By Administrator
8~10 min read

array数组是numpy最核心的数据结构


array对象的属性

array的属性主要包括:shape、ndim、size、dtype

# 先创建好初始数据
import numpy as np
x = np.array([1,2,3,4,5,6,7,8])
y = np.array([
    [1,2,3,4,5,6,7,8],
    [1,2,3,4,5,6,7,8]
])

image-20201217234244586

  • shape:获取array的形状,即行数和列数

    x.shape
    y.shape

    image-20201217234644425

  • ndim:获取array的维度数量

    x.ndim
    y.ndim

    image-20201217235024843

  • size:获取array的元素数量

    x.size
    y.size

    image-20201217235131452

  • dtype:获取array的数据类型

    x.dtype
    y.dtype

    image-20201217235240007

python
python
License:  CC BY 4.0
Share

Further Reading

Jun 18, 2025

python包管理神器:UV

目前 UV 因其优势,已被大量的python开源项目使用。简单整理了一些命令,不到 UV 功能的 1/5,更多功能慢慢探索。 安装 # mac brew install uv ​ # win powershell -c "irm https://astral.sh/uv/install.ps1 |

May 27, 2025

python中一些很好用的工具类模块

contextlib 此模块为 with 语句提供了一些工具,简化了 with的使用。 @contextlib.contextmanager 它将一个生成器函数转换为一个上下文管理器。而无需创建一个类或单独的 __enter__() 和 __e

Apr 21, 2025

Typing

类型注释让python 有了更好的编辑器提示功能。 基础使用 对函数参数和返回值,进行类型注释 def surface_area_of_cube(edge_length: float) -> str:    return f"The surface area of the cube is {6 *

OLDER

01-numpy的简介及array的创建

NEWER

一次PostgreSQL在windows安装中的问题

Recently Updated

  • 使用 claude api遇到的问题
  • 一些开发中使用的 linux运维命令
  • python包管理神器:UV
  • ollama-大模型的部署与使用
  • 为jupyter增加可选的python内核

Trending Tags

Halo 运维 postgresql 设计模式 linux就该这么学 nas rag odoo python 文本切分

Contents

©2025 刘刚刚的blog. Some rights reserved.

Using the Halo theme Chirpy