I have a numpy array let's say
([1,2,3,4,5,6,7])
I want to split it into a 2d array so that the last element is in its own array, e.g.
([1,2,3,4,5,6],[7])
How exactly did I do this?
Use np.split-
np.split
np.split(a,[-1])
Run Example -
In [105]: a Out[105]: array([1, 2, 3, 4, 5, 6, 7]) In [106]: np.split(a,[-1]) Out[106]: [array([1, 2, 3, 4, 5, 6]), array([7])]
Source: https://habr.com/ru/post/1669071/More articles:What is the point of using JWT with ASPNet.Identity? - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1669067/how-does-apache-spark-send-functions-to-other-machines-under-the-hood&usg=ALkJrhjef7CUyrj7mjo8T1-c85jR5VwWSAAvoiding repetition if the smell of else series code is c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1669069/numpy-2d-array-change-all-values-to-the-right-of-nans&usg=ALkJrhilwIAtsGTrhyMi3Wl1wLll0-b3AgAngular 2 - ng-bootstrap popup menu with formControlName - angularDoes FutureOr type reided future / ? - dartPostgres chooses BTREE instead of BRIN - indexingpycURL; Received HTTP 400 code from proxy after CONNECT - pythonpandas pivot table rename columns - pythonКак настроить стратегию отказа при добавлении актера в ActorySystem - scalaAll Articles