data = {
'list_id' : [[50, None],[20, 68],[10, 7],[73, 4, 26, 3],[50, None],[68, 20, 61, 62],[68, None]]
}
df = pd.DataFrame.from_dict(data)
print (df)
I tried the below steps,
expected Output
data = {
'list_id' : [[50],[20, 68],[10, 7],[73, 4, 26, 3],[50],[68, 20, 61, 62],[68]]
}
df = pd.DataFrame.from_dict(data)
print (df)
list_id
0 [50]
1 [20, 68]
2 [10, 7]
3 [73, 4, 26, 3]
4 [50]
5 [68, 20, 61, 62]
6 [68]
df[['list_id']] = df['list_id'].apply(lambda el: [ f'' if x is None else x for x in el])
df[['list_id']] = df['list_id'].apply(lambda el: [ f'' if x is None for x in el])
Need to replace None values in column with list elements, either as an empty '' string or None being removed, not sure about np.nan..