python - SFrame from numpy array -


i create sframe numpy array:

what want:

np.arange(16).reshape(4, 4)  

=>

+----+----+----+----+ | 0  | 1  | 2  | 3  | +----+----+----+----+ | 0  | 1  | 2  | 3  | | 4  | 5  | 6  | 7  | | 8  | 9  | 10 | 11 | | 12 | 13 | 14 | 15 | +----+----+----+----+ [4 rows x 4 columns] 

if do:

print sframe(np.arange(16).reshape(4, 4)) 

i get:

+--------------------------+ |            x1            | +--------------------------+ |   [0.0, 1.0, 2.0, 3.0]   | |   [4.0, 5.0, 6.0, 7.0]   | |  [8.0, 9.0, 10.0, 11.0]  | | [12.0, 13.0, 14.0, 15.0] | +--------------------------+ [4 rows x 1 columns] 

i can want if convert numpy array pandas dataframe , pandas dataframe sframe:

print sframe(pd.dataframe(np.arange(16).reshape(4, 4)))  +----+----+----+----+ | 0  | 1  | 2  | 3  | +----+----+----+----+ | 0  | 1  | 2  | 3  | | 4  | 5  | 6  | 7  | | 8  | 9  | 10 | 11 | | 12 | 13 | 14 | 15 | +----+----+----+----+ [4 rows x 4 columns] 

the question is: "how can create sfame numpy array in way pandas dataframe reads it(array nxm => dataframe n rows , m columns), without using pandas intermediate step?

i has issue, find multi-indexing hard in sframe.

may silly fix still workable;

from graphlab import sframe,sarray  data=np.arange(16).reshape(4, 4).t  sf=sframe(map(sarray,data) 

should result in this

x1  x2  x3  x4 0   1   2   3 4   5   6   7 8   9   10  11 12  13  14  15 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -