Saving outcomes if Error while applying map function on dataset

mariosasko
Mon, 13 Feb 2023 15:43:38 +0000

Hi! You can use try/except to catch the error and return None to avoid interrupting the processing procedure:

def get_api_response(ex):
    try:
        # API call...
        return {"response": "..."}
    except Exception:
        return {"response": None}

dataset.map(get_api_response)