Merge multidimensional array ndarray and pythonndarray in python
Http://blog.csdn.net/pipisorry/article/details/39215089
Merge multiple dimensions of ndarray in numpy
Implement the functions of matlab data1 = [r. * cos (t), r. * sin (t:
Implement matlab data = [data1; data2 ];
Data_pos =
[[-0.00870993 0.84913981]
[-0.28528784 0.2612078]
[-0.4475744 0.43677346]
[-0.2473318-0.89767194]
[0.45242961-0.02112013]
[-0.10939665-0.67678242]
[0.59871918-0.27938622]
[-0.67484345 0.18797474]
[0.04628507-0.14074493]
[0.27405096 0.91563243]
Data_neg =
[-1.7135893-0.13973792]
[-1.69338611 0.4599861]
[0.4576769 1.68156328]
[0.1199849-1.00716347]
[0.94074345 1.03022516]
[-0.68055284-1.84048252]
[1.35995126 0.11136057]
[1.04061602 0.89650711]
[-1.79624533 0.27777414]
[0.78416735 1.47684656]
Data = np. append (data_pos, data_neg, axis = 0)
Data =
[[-5.964404e-01 4.06034824e-01]
[4.82952945e-01-1.20121194e-01]
[-5.77977122e-01-3.79254425e-01]
[-7.20.40595e-01 5.30272266e-01]
[1.51701741e-01-2.33477263e-01]
[-3.35472827e-04 4.38564615e-01]
[-9.62188462e-01 2.36012802e-01]
[5.44815124e-01-5.36231442e-01]
[-2.76687718e-01-3.30882444e-01]
[2.29255115e-01-5.06503177e-01]
[3.26605661e-01-1.86522383e + 00]
[5.96712043e-01 1.46382588e + 00]
[1.67364905e + 00 9.05077496e-01]
[-1.48502012e + 00-3.60574944e-01]
[-1.44121871e + 00-1.33299063e + 00]
[1.39996884e + 00 1.79711008e-01]
[-6.20.03150e-02-1.53043305e + 00]
[4.25909425e-01-1.10527802e + 00]
[-7.00656660e-01 8.22864651e-01]
[-6.55652372e-01-1.80101194e + 00]
From: http://blog.csdn.net/pipisorry/article/details/39215089
Merge arrays in python numpy
... You don't need to worry about this problem. You are a one-dimensional array, which can be directly converted into a list, directly added and converted into an array.
In python, how does one merge the values of the same array?
X = [['beijing', 2], ['beijing', 1], ['tianjin ', 1], ['fujian', 1]
Tmp = {}
For v in x:
Tmp [v [0] = tmp. get (v [0]) and tmp [v [0] + v [1] or v [1]
X = [[k, v] for (k, v) in tmp. items ()]
Print (x)
Output:
[['Beijing', 3], ['fujian ', 1], ['tianjin', 1]