How to save a list as numpy array in python?

前端 未结 9 926
心在旅途
心在旅途 2020-12-04 08:27

Is possible to construct a NumPy array from a python list?

9条回答
  •  心在旅途
    2020-12-04 08:47

    First of all, I'd recommend you to go through NumPy's Quickstart tutorial, which will probably help with these basic questions.

    You can directly create an array from a list as:

    import numpy as np
    a = np.array( [2,3,4] )
    

    Or from a from a nested list in the same way:

    import numpy as np
    a = np.array( [[2,3,4], [3,4,5]] )
    

提交回复
热议问题