Placeholder Image

字幕列表 影片播放

由 AI 自動生成
  • Hello everyone, a warm welcome to you.

    大家好,熱烈歡迎你們的到來。

  • In today's video, we are going to see how to stock two arrays in NumPy.

    在今天的視頻中,我們將瞭解如何在 NumPy 中存儲兩個數組。

  • So as you know, in NumPy, the arrays are the object, right?

    大家都知道,在 NumPy 中,數組就是對象,對嗎?

  • So if two arrays are given, how to stock those arrays or how to combine those two arrays.

    是以,如果給定了兩個數組,如何將這兩個數組儲存起來,或者如何將這兩個數組組合起來。

  • So we have few functions in NumPy for that.

    是以,NumPy 中有幾個函數可以實現這一功能。

  • So let's see how to do it.

    讓我們來看看如何做到這一點。

  • So first, let me create two arrays.

    首先,讓我創建兩個數組。

  • I'm importing NumPy.

    我正在導入 NumPy。

  • And let me create two arrays here.

    讓我在這裡創建兩個數組。

  • Let's take an object as AR1.

    讓我們以 AR1 為對象。

  • And AR2.

    還有 AR2。

  • So using array function, I'm creating two arrays here.

    使用數組函數,我在這裡創建了兩個數組。

  • So here we have AR1 and AR2, two one-dimensional arrays, right?

    這裡有 AR1 和 AR2 兩個一維數組,對嗎?

  • And if I wanted to combine these two arrays, I can use stock function.

    如果我想合併這兩個數組,可以使用股票函數。

  • So first, let me show you how to use stock function for that.

    所以,首先讓我來教你如何使用股票功能。

  • So let's say stock and I need to pass both the arrays inside this function.

    比方說,我需要在這個函數中傳遞股票和數組。

  • So this will combine these two arrays, right?

    這樣就可以將這兩個數組合並起來,對嗎?

  • So as you can see, it combines these two arrays row wise.

    是以,正如你所看到的,它將這兩個數組按行排列組合在一起。

  • And I have given both one-dimensional array in the stock function.

    我在股票函數中給出了兩個一維數組。

  • And if you see the output, it has returned as two dimension, right?

    如果你看到輸出結果,它返回的是二維,對嗎?

  • So if you check the shape of this, you can see that we have two dimension array here, right?

    所以,如果你查看一下這個形狀,就會發現這裡有一個二維數組,對嗎?

  • So by default, this function combines row wise.

    是以,默認情況下,該函數會按行進行組合。

  • But let's say if I wanted to combine it column wise, then still I can use this function.

    但如果我想按列進行組合,還是可以使用這個函數。

  • And there is a parameter called axis.

    還有一個參數叫做軸。

  • So I can include this parameter where I can give as one.

    是以,我可以把這個參數作為一個參數。

  • So by default, this parameter will take value as zero, which refers to rows, okay?

    是以,默認情況下,這個參數的值為 0,也就是行數,明白嗎?

  • When axis is zero, it refers to rows and when axis is one, it refers to columns.

    當座標軸為 0 時,它指的是行,當座標軸為 1 時,它指的是列。

  • So here, if I try to combine these two arrays using stock function by giving axis as one, you can see that these two arrays are combined column wise, right?

    是以,在這裡,如果我嘗試使用 stock 函數將這兩個數組合並在一起,將軸作為一個軸,你可以看到這兩個數組是按列合併的,對嗎?

  • So you can use stock function to combine two arrays, okay?

    是以,你可以使用股票函數來組合兩個數組,好嗎?

  • And now let's see the other function like vstock.

    現在我們來看看其他功能,比如 vstock。

  • So here I'm going to call this vstock.

    在這裡,我把它叫做 vstock。

  • So vstock stands for vertical stock, okay?

    Vstock代表垂直庫存,明白嗎?

  • If you wanted to combine two arrays vertically, right?

    如果你想垂直組合兩個數組,對嗎?

  • So you can use this vstock and let me pass both the arrays inside this function.

    是以,你可以使用這個 vstock,讓我在這個函數中傳遞兩個數組。

  • So here it gives you again, if you see both are one dimensional array and the output which you got is a two dimensional array, right?

    所以,這裡它又給了你一次機會,如果你看到兩個都是一維數組,而你得到的輸出是二維數組,對嗎?

  • So if you check the shape of it, you can see it's two dimension, right?

    所以,如果你檢查一下它的形狀,就會發現它是二維的,對嗎?

  • So vstock gives you, it takes two one dimensional array and gives you a two dimensional array where it combines them vertically, right?

    是以,vstock 可以獲取兩個一維數組,然後生成一個二維數組,將它們垂直組合起來,對嗎?

  • And if you wanted to combine or stack the array horizontally, then we have function for that called hstock.

    如果你想水準合併或堆疊數組,我們有一個名為 hstock 的函數。

  • So again, I'm going to pass both these arrays.

    是以,我要再次傳遞這兩個數組。

  • And you can see that the two arrays are stacked horizontally, right?

    你可以看到這兩個陣列是水準堆疊的,對嗎?

  • And you can see that it's one dimensional array.

    你可以看到這是一個一維數組。

  • So hstock by default gives you it when it takes two one dimensional array, it gives you one dimensional array as the output, right?

    是以,默認情況下,當 hstock 使用兩個一維數組時,它的輸出是一維數組,對嗎?

  • So these are the difference between stock, vstock and hstock.

    是以,這些就是股票、Vstock 和 Hstock 之間的區別。

  • So you can stack two arrays using these functions.

    是以,您可以使用這些函數堆疊兩個數組。

  • Thank you.

    謝謝。

Hello everyone, a warm welcome to you.

大家好,熱烈歡迎你們的到來。

字幕與單字
由 AI 自動生成

單字即點即查 點擊單字可以查詢單字解釋