2014-04-12 6 views

risposta

14

è quasi ettari d it! È possibile utilizzare -1.

>>> foo.reshape(-1, 2) 
array([[ 2, 3], 
     [ 4, 5], 
     [ 6, 7], 
     [ 8, 9], 
     [10, 11]]) 

quanto reshape documenti dicono:

newshape : int or tuple of ints 
    The new shape should be compatible with the original shape. If 
    an integer, then the result will be a 1-D array of that length. 
    One shape dimension can be -1. In this case, the value is inferred 
    from the length of the array and remaining dimensions.