Created
July 19, 2019 09:44
-
-
Save wiccy46/62a8fc7f5e25fea172f716e7c3ab0d72 to your computer and use it in GitHub Desktop.
[numpy_subset]A collection of different number subsetting #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """To get a new array by subsetting columns of different np.ndarray""" | |
| a = np.array([[1,2],[3,4],[5,6]]) | |
| b = np.array([[10,20],[30,40],[50,60]]) | |
| # Using zip | |
| [(a_s[0], b_s[0]) for a_s, b_s in zip(a,b)] | |
| # A faster way is to concat and ravel, use ('float, float') if float number. | |
| np.c_[a[:,0],b[:,0]].view('i,i').ravel() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment