avatar

刘刚刚的blog

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

  • 首页
  • 大模型应用
  • 常用软件/工具
  • Halo
  • 关于
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

Apr 21, 2025

Typing

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

Feb 25, 2025

python多进程多线程下的计数及日志打印

注意点: 需要保证在多进程内的进程锁是同一个 需要保证在单进程中的多线程内线程锁是同一个 # logger.py import multiprocessing import threading ​ ​ class Logger_test:    def __init__(self, process

Dec 25, 2022

python-迭代器、生成器、协程

迭代器 Python中当容器对象提供了对迭代的支持时,可以通过container.__iter__()来返回一个迭代器对象。 迭代器需要支持以下两个方法,这两个方法共同构成了迭代器协议: iterator.__iter__() 该方法返回迭代器本身,这个方法是配合for和in使用所必须的。 iter

OLDER

01-numpy的简介及array的创建

NEWER

一次PostgreSQL在windows安装中的问题

Recently Updated

  • 文本切分-语义分割(Semantic Chunking)
  • dify 并发配置优化
  • Typing
  • 大模型返回中json_schema与json_mode的区别
  • Async

Trending Tags

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

Contents

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

Using the Halo theme Chirpy