This is a follow up of this question: Extract non- empty values from the regex array output in python
I have a DF with columns "col" and "col1" of type 'numpy.ndarray' and looks like :
col col1
[[5, , , ,]] [qwe,ret,der,po]
[[, 4, , ,][, , 5, ]] [fgk,hfrt]
[] []
[[, , , 9]] [test]
I want my output as:
col col1
5 qwe,ret,der,po
5 fgk,hfrt
0 NOT FOUND
9 test
Please note column "col", second row has maximum of the two entries in the output. I tried the solution provided in the above link but its giving ValueError "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"
Thanks
Edit: Dictionary form of my DF with column "col":
{'col': {0: array([['5', '', '', '', '', '']],
dtype='|S1'), 1: array([], dtype=float64), 2: array([], dtype=float64), 3: array([], dtype=float64), 4: array([], dtype=float64), 5: array([['8', '', '', '', '', '']],
dtype='|S1'), 6: array([], dtype=float64), 7: array([], dtype=float64), 8: array([], dtype=float64), 9: array([], dtype=float64), 10: array([], dtype=float64), 11: array([['', '8', '', '', '', '']],
dtype='|S1'), 12: array([], dtype=float64), 13: array([], dtype=float64), 14: array([], dtype=float64), 15: array([['7', '', '', '', '', '']],
dtype='|S1'), 16: array([], dtype=float64)}}