In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use numpy related functions". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Np.where
First of all, it is emphasized that the where () function returns different values for different inputs.
1. When the array is an one-dimensional array, the value returned is an one-dimensional index, so there is only one set of index arrays.
2. When the array is a two-dimensional array, the array value that meets the condition returns the location index of the value, so there are two sets of index arrays to represent the position of the value. The following example:
Import numpy as npa=np.reshape (np.arange (20), (4Power5)) aarray ([0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]) b = np.where (a > 10) b (array ([2, 2, 2, 2, 3, 3, 3, 3, 3], dtype=int64), array ([1, 2, 3) 4, 0, 1, 2, 3, 4], dtype=int64)) b [0] [:] array ([2, 2, 2, 2, 3, 3, 3, dtype=int64) b [0] array ([2, 2, 2, 2, 3, 3, 3, 3, 3, 3], dtype=int64) b [1] array ([1, 2, 3, 4, 0, 1, 2, 3, 4], dtype=int64)
An is a two-dimensional array, b is the returned index, the index is divided into two parts: row index and column index, b [0] is the row index, b [1] is the column index.
Np.tile
His function is to repeat an array. For example, tile (A _ Query n), the function is to repeat array A n times to form a new array. Example:
Import numpy as npa = np.tile (a, (1,4)) barray ([[1pyr2, (1,4) barray)]) b = np.tile (a, 4) barray ([1pyr2, 1pyr3, 1pyr3, 1pas, 2p3) d = np.tile (a, (2,4)) darray 2, 3], [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3])
From the above example, we can see that b = np.tile (a, (1,4)) generates a two-dimensional array, while b = np.tile (a, 4) generates an one-dimensional array, which repeats a four times.
That's all for the content of "how to use numpy related functions". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.