python - 2D numpy array from a pandas dataframe row with delimited range -


i newbie on python , loaded big data csv pandas dataframe. however, cannot find method create 2d array each row of dataframe each row of new np array correspond x range of values. example, in code:

import pandas pd import numpy np  data = pd.read_csv("categorization/dataall10overfit.csv",header=none) #print(data) rec = data.iloc[:,0:3968] # outputs rows x 3969 columns 

there 3968 values in each row of dataframe , create 124x32 numpy array each block of 124 values become row in 2d np array. know c# , there work fill new array using loop guess there should one-line function in python split data of dataframe's arrow new np array. if question duplicated, please refer me other post. in advance

if want 2d arrays within 1 3d array can do:

arr = np.zeros((data.shape[0], 124, 32))  idx, row in data.iterrows():     arr[idx] = np.asarray(row).reshape(124, 32) 

or one-liner list of arrays:

arr = [np.asarray(row).reshape(124, 32) idx, row in data.iterrows()] 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -