Get the App
SLTechnology News&Howtos  ›  Development  › 

How Python finds the index of an element in a two-dimensional array

Shulou Source: shulou.com Published: 2022-06-01 13:17:41 09月22日 Update

This article mainly introduces how Python finds the index of an element in the two-dimensional array of related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this Python how to find out the index of an element in the two-dimensional array article will have a harvest, let's take a look.

1. The index of the array

I'm using the iloc function. The imported data is data, and the index data.iloc [iJournal j], I represents rows, j represents columns. If you want to index all the row elements after the line I, use data.iloc [iRJ], and all rows before the line I, use data.iloc [: iMagee j].

two。 Splicing of arrays

You can use the append function. Np.apend (a _ r _ b), an and b are arrays to be spliced.

Because I need to splice one-dimensional array into two-dimensional array by row, select vstack function, can achieve vertical splicing. Np.vstack ((a) b))

3. Array deletes one or more rows of elements

I'm using the drop function. Data.drop ([I]), which represents the deletion of line I elements. The drop function can also delete multi-line elements, data.drop ([iJJ _ k]).

Python finds the index of an element in a two-dimensional array and defines the function.

Look at the code # function: find the index of an element in a two-dimensional array # function: return all index numbers def found (List,AimList): # List: search array, AimList: target element print ('original array is:') print (List) print ('target array is:') print (AimList) num= [] iObject0 length=len (List) while I

Tags: Array element index two-dimensional function goal representative knowledge content article multiple lines one line code value location function simple operation data article direction Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi vpn Xiaomi OPPO Reno NVidia