V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Ewig
V2EX  ›  Python

Python numpy 如何看几维?

  •  
  •   Ewig · Jan 19, 2019 · 3615 views
    This topic created in 2665 days ago, the information mentioned may be changed or developed.
    >>> import numpy as np
    >>> a=np.array([[1,2,3],[3,5,6]])
    >>> b=np.array([1,2,3,4,5],ndmin=2)
    >>> print(b)
    [[1 2 3 4 5]]
    >>> b.shape
    (1, 5)
    >>> com=np.array([a,b,c])
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'c' is not defined
    >>> com=np.array([a,b,c])
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'c' is not defined
    >>> c=np.array([[3,2,3],[3,5,6]])
    >>> com=np.array([a,b,c])
    >>> com
    array([array([[1, 2, 3],
    [3, 5, 6]]), array([[1, 2, 3, 4, 5]]),
    array([[3, 2, 3],
    [3, 5, 6]])], dtype=object)
    >>> com.shape
    (3,)
    >>> b.shape
    (1, 5)
    >>> c.shape
    (2, 3)
    >>>


    比如这个怎么看维度啊?(1, 5) 这个是二维的图怎么画出来啊
    4 replies    2019-01-21 09:27:27 +08:00
    aijam
        1
    aijam  
       Jan 19, 2019
    这个很简单啊
    dangyuluo
        2
    dangyuluo  
       Jan 19, 2019
    不看文档的么。。。
    ```python
    a.dim
    ```
    xiao38245
        3
    xiao38245  
       Jan 19, 2019
    a.shape, 好好看看文档吧
    Zeeech
        4
    Zeeech  
       Jan 21, 2019
    @dangyuluo 正解
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1761 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 16:18 · PVG 00:18 · LAX 09:18 · JFK 12:18
    ♥ Do have faith in what you're doing.