Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report