I have the below for loop and am try to check first if the tuple(row) item in position 10 is Nan
i=0
for row in df.iterrows():
if row[1][10] != None:
names = row[1][10].split(',')
for name in names:
df2.loc[i,:] = row[1][:]
i=i+1
else:
i=i+1
I thought I could use if row[1][10] != None: but it doesnt seem to work, anyone know the solution?
>Solution :
Can use pd.isnull(row[1][10]) instead of if row[1][10] != None.
Example:
i=0
for row in df.iterrows():
if pd.isnull(row[1][10]):
df2.loc[i,:] = row[1][:]
i=i+1
else:
names = row[1][10].split(',')
for name in names:
df2.loc[i,:] = row[1][:]
df2.loc[i,'name'] = name
i=i+1
Also please do give feedback about this solution.