How huge is the data? If memory isn't a problem and you have the data in a list this works for you example input:
input = [['SE01_inf', 'name', [], 'NA', []],\
['SE01_loc', 'NA', 'loc', 'NA', []],\
['SE01_id', 'NA', [], '123', []],\
['SE01_1_inf', 'name1', [], 'NA', []],\
['SE01_1_loc', 'NA', 'loc', 'NA', []]]
output = {}
for row in input:
id = row[0][:row[0].rfind('_')]
if id not in output:
output[id] = [id] + row[1:]
else:
output[id] = [new if old in ('NA', []) else old for new, old in zip(row, output[id])]
print output.values()
Produces the output:
[['SE01', 'name', 'loc', '123', []], ['SE01_1', 'name1', 'loc', 'NA', []]]