Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. array(['Subject_ID', 'tube_label', 'sample_#', 'Relabel',
  2. 'sample_ID','cortisol_value', 'Group'], dtype='<U14')
  3.  
  4. array([['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
  5. ['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC'],], dtype=object)
  6.  
  7. testing = np.concatenate((header, body), axis=0)
  8.  
  9. A = np.array(['Subject_ID', 'tube_label', 'sample_#', 'Relabel',
  10. 'sample_ID','cortisol_value', 'Group'], dtype='<U14')
  11.  
  12. B = np.array([['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
  13. ['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC'],], dtype=object)
  14.  
  15. res = np.vstack((np.array([A]), B))
  16.  
  17. print(res)
  18.  
  19. array([['Subject_ID', 'tube_label', 'sample_#', 'Relabel', 'sample_ID',
  20. 'cortisol_value', 'Group'],
  21. ['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
  22. ['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC']], dtype=object)
  23.  
  24. In [1]: import numpy as np
  25.  
  26. In [2]: arr1 = np.array(['Subject_ID', 'tube_label', 'sample_#', 'Relabel',
  27. ...: 'sample_ID','cortisol_value', 'Group'], dtype='<U14')
  28. ...:
  29.  
  30. In [3]: arr2 = np.array([['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
  31. ...: ['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC'],], dtype=object)
  32. ...:
  33.  
  34. In [4]: arr1.shape
  35. Out[4]: (7,)
  36.  
  37. In [5]: arr2.shape
  38. Out[5]: (2, 7)
  39.  
  40. In [8]: concatenated = np.concatenate((arr1[None, :], arr2), axis=0)
  41.  
  42. In [9]: concatenated.shape
  43. Out[9]: (3, 7)
  44.  
  45. In [10]: concatenated
  46. Out[10]:
  47. array([['Subject_ID', 'tube_label', 'sample_#', 'Relabel', 'sample_ID',
  48. 'cortisol_value', 'Group'],
  49. ['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
  50. ['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC']], dtype=object)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement