Python:numpy库中的一些函数简介、使用方法之详细攻略
Python:numpy庫中的一些函數(shù)簡(jiǎn)介、使用方法之詳細(xì)攻略
?
?
?
目錄
numpy庫中的一些函數(shù)簡(jiǎn)介、使用方法
1、np.concatenate()
1.1、函數(shù)案例
1.2、函數(shù)用法
?
?
numpy庫中的一些函數(shù)簡(jiǎn)介、使用方法
1、np.concatenate()
1.1、函數(shù)案例
import numpy as npa=np.array([1,2,3]) b=np.array([11,22,33]) c=np.array([44,55,66]) d=np.concatenate((a,b,c),axis=0) # 默認(rèn)情況下,axis=0可以不寫 print(d) #輸出array([ 1, 2, 3, 11, 22, 33, 44, 55, 66]),對(duì)于一維數(shù)組拼接,axis的值不影響最后的結(jié)果?
1.2、函數(shù)用法
| concatenate Found at: numpy.core.multiarray concatenate((a1, a2, ...), axis=0, out=None) ? ? Join a sequence of arrays along an existing axis. ? ? Parameters ? ? ---------- ? ? a1, a2, ... : sequence of array_like. The arrays must have the same shape, except in the dimension??corresponding to `axis` (the first, by default). ? ? axis : int, optional.?The axis along which the arrays will be joined. ?Default is 0. ? ? out : ndarray, optional.?If provided, the destination to place the result. The shape? must be correct, matching that of what concatenate would have???returned if no??out argument were specified. ? ?? ? ? Returns ? ? ------- ? ? res : ndarray ? ? The concatenated array. | 在:numpy.core.multiarray找到連接
|
| ? ? See Also ? ? -------- ? ? ma.concatenate : Concatenate function that preserves input???masks. ? ? array_split : Split an array into multiple sub-arrays of equal or ? ? near-equal size. ? ? split : Split array into a list of multiple sub-arrays of equal size. ? ? hsplit : Split array into multiple sub-arrays horizontally???(column wise) ? ? vsplit : Split array into multiple sub-arrays vertically (row wise) ? ? dsplit : Split array into multiple sub-arrays along the 3rd axis? (depth). ? ? stack : Stack a sequence of arrays along a new axis. ? ? hstack : Stack arrays in sequence horizontally (column wise) ? ? vstack : Stack arrays in sequence vertically (row wise) ? ? dstack : Stack arrays in sequence depth wise (along third? dimension) ? ?? ? ? Notes ? ? ----- ? ? When one or more of the arrays to be concatenated is a? MaskedArray,?? this function will return a MaskedArray object instead of an? ndarray, but the input masks are *not* preserved. In cases where a???MaskedArray??is expected as input, use the ma.concatenate function from? the masked??array module instead. | 另請(qǐng)參閱 -------- 馬。保存輸入掩碼的連接函數(shù)。 array_split:將一個(gè)數(shù)組分割成多個(gè)相等或的子數(shù)組 與大小。 分割:將數(shù)組分割成相同大小的多個(gè)子數(shù)組。 hsplit:水平(按列)將數(shù)組分割為多個(gè)子數(shù)組 垂直(按行)將數(shù)組分割為多個(gè)子數(shù)組 dsplit:沿著第三軸(深度)將數(shù)組分割成多個(gè)子數(shù)組。 堆棧:將數(shù)組序列沿著一個(gè)新的軸進(jìn)行堆棧。 hstack:水平排列(按列排列) 垂直(行向)按順序堆疊數(shù)組。 dstack:按深度順序排列的堆棧數(shù)組(沿三維方向) 筆記 ----- 當(dāng)一個(gè)或多個(gè)要連接的數(shù)組是一個(gè)MaskedArray時(shí),這個(gè)函數(shù)將返回一個(gè)MaskedArray對(duì)象而不是ndarray,但是輸入掩碼*不*保留。在需要MaskedArray作為輸入的情況下,使用ma。連接函數(shù)從掩碼數(shù)組模塊代替。 |
| ? ? Examples ? ? This function will not preserve masking of MaskedArray? | ? |
?
?
?
?
總結(jié)
以上是生活随笔為你收集整理的Python:numpy库中的一些函数简介、使用方法之详细攻略的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WPS:Excel数据表格查询定位技巧之
- 下一篇: Python:wordcloud.wor