User Tools

Site Tools


numpy_exercises

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
numpy_exercises [2020/10/17 19:26] prasanthinumpy_exercises [2020/10/18 02:55] prasanthi
Line 2: Line 2:
 Q. Given two one dimensional arrays, how to combine them into a 2d numpy array? Q. Given two one dimensional arrays, how to combine them into a 2d numpy array?
  
-A. use np.column_stack((c1, c2))+A. use <nowiki>np.column_stack((c1, c2))</nowiki>
  
 <code> <code>
Line 33: Line 33:
 2 2
 </code> </code>
-You can also get the same result by doing np.vstack((c1, c2)).T . But I like the column_stack() approach as it gives the correct shape right away and does not require a transpose.+You can also get the same result by doing <nowiki>np.vstack((c1, c2)).T</nowiki> . But I like the column_stack() approach as it gives the correct shape right away and does not require a transpose.
  
 <code> <code>
Line 51: Line 51:
 True True
 </code> </code>
 +
 +Ref:-
 +  * https://openlibrary.org/books/OL26834151M/Python_for_Data_Analysis_Data_Wrangling_with_Pandas_NumPy_and_IPython -> Appendix A "Advanced Numpy" -> "A.2 Advanced Array Manipulation" -> "Concatenating and Splitting Arrays" -> "Table A-1. Array concatenation functions" - contains a list of similar functions and their description.
 +  * https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html - np.array_equal() can be used to check if two arrays are equal
 +  * https://stackoverflow.com/questions/17710672/create-2-dimensional-array-with-2-one-dimensional-array
 +
 +tags:- combine two numpy arrays into 2d array
  
numpy_exercises.txt · Last modified: 2020/10/25 04:39 by prasanthi