New to Python but here is the code I'm using:
lst2 = list()
for i in lst1:
try:
df1 = pd.DataFrame(i.QID1)
except AttributeError:
"null"
df2 = lst2.append(df1)
lst2 is generating the output that I want, but the instances where i.QID1 does not exist are being populated by the data from the previous instance, instead of "null". I'm sure it's because of the 'except AttributeError' piece, just not sure how to fix it. As I say I'm a noob.
Thanks so much for any help!