日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Python:numpy库中的一些函数简介、使用方法之详细攻略

發(fā)布時(shí)間:2025/3/21 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python:numpy库中的一些函数简介、使用方法之详细攻略 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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找到連接
連接((a1, a2,…),axis=0, out=None)
沿著現(xiàn)有的軸連接數(shù)組序列。
參數(shù)
----------
a1, a2,…:數(shù)組類型的序列。數(shù)組必須具有相同的形狀,除了與“axis”對(duì)應(yīng)的維度(默認(rèn)情況下為第一個(gè)維度)。
axis: int,可選。數(shù)組連接的軸線。默認(rèn)值為0。
out : ndarray,可選。如果提供,放置結(jié)果的目的地。形狀必須正確,如果沒有指定out參數(shù),則匹配concatenate將返回的形狀。


返回
?-------
res: ndarray
連接后的字符串?dāng)?shù)組。

? ? 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
? ? --------
? ? >>> a = np.array([[1, 2], [3, 4]])
? ? >>> b = np.array([[5, 6]])
? ? >>> np.concatenate((a, b), axis=0)
? ? array([[1, 2],
? ? [3, 4],
? ? [5, 6]])
? ? >>> np.concatenate((a, b.T), axis=1)
? ? array([[1, 2, 5],
? ? [3, 4, 6]])

? ? This function will not preserve masking of MaskedArray?
? ? ?inputs.
? ??
? ? >>> a = np.ma.arange(3)
? ? >>> a[1] = np.ma.masked
? ? >>> b = np.arange(2, 5)
? ? >>> a
? ? masked_array(data = [0 -- 2],
? ? mask = [False ?True False],
? ? fill_value = 999999)
? ? >>> b
? ? array([2, 3, 4])
? ? >>> np.concatenate([a, b])
? ? masked_array(data = [0 1 2 2 3 4],
? ? mask = False,
? ? fill_value = 999999)
? ? >>> np.ma.concatenate([a, b])
? ? masked_array(data = [0 -- 2 2 3 4],
? ? mask = [False ?True False False False False],
? ? fill_value = 999999)

?

?

?

?

?

總結(jié)

以上是生活随笔為你收集整理的Python:numpy库中的一些函数简介、使用方法之详细攻略的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。