I find myself doing a lot of data transformation like this:
mydf = pd.DataFrame()
for i in my_array:
data = {}
try:
data["foo"] = i["foo"] ## more simple
except:
data["foo"] = ""
...
try:
data["baz"] = item["foo"]["baz"] ## more complex
except:
data["baz"] = ""
mydf = mydf.append(data, ignore_index = True)
It seems repetitive do many try/except statements this way. How would I write a function to manage this scenario or is what I'm doing the best practise?