I have a pandas dataframe with an 2d array stored in one of the columns: "mels" In other columns of the Dataframe I have start and end location of columns I will like to extract from 2d array 'mels'. Here is how my Dataframe looks like:
## Data Frame which has Start Location of a segment : HS_Start
## & end location of a segment : HS_End
df_sound_loc.ix[:,-3:].head(5)[enter image description here][1]
HS_Start | HS_End | mels | ---------| -------|------- ---13 | ---25 | [[0.0752865622903, 0.00439239454838, 0.0182232... |
For Example HS_Start: 13 and HS_End is 25, then I am expecting all rows with 13 to 25 column values from respective "mels" array: mels[:,13:25]
so on and so forth for all rows
# Column mels is a 2D array of 128 rows and 680 columns
df_sound_loc.ix[1,-1].shape
(128,680)
Want to extract only the Columns from mels: 2d array between HS_Start & HS_End numbers
print(df_sound_loc['mels'][:,df_sound_loc['HS_Start']:df_sound_loc['HS_End']])
Got following error:
If key is contained, would have returned by now
ValueError: Can only tuple-index with a MultiIndex
I am new to Python and Dataframe operations. please advise