numpy.plit

轉載自,侵權刪。僅爲方便查閱http://blog.csdn.net/autoliuweijie/article/details/51968315

概述:

可以用於把narray分成幾份。

示例:

numpy.plit(ary, indices_or_sections, axis=0)

>>> x = np.arange(9.0)
>>> np.split(x, 3)
[array([ 0.,  1.,  2.]), array([ 3.,  4.,  5.]), array([ 6.,  7.,  8.])]


>>> x = np.arange(8.0)
>>> np.split(x, [3, 5, 6, 10])
[array([ 0.,  1.,  2.]), array([ 3.,  4.]), array([ 5.]), array([ 6.,  7.]), array([], dtype=float64)]

numpy.array_split(ary, indices_or_sections, axis=0)

功能與split一樣,唯一的區別是 array_split allows indices_or_sections to be an integer that does not equally divide the axis.

>>> x = np.arange(8.0)
>>> np.array_split(x, 3)
[array([ 0.,  1.,  2.]), array([ 3.,  4.,  5.]), array([ 6.,  7.])]

參考:

split():http://docs.scipy.org/doc/numpy/reference/generated/numpy.split.html

array_aplit():http://docs.scipy.org/doc/numpy/reference/generated/numpy.array_split.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章