The answer for me was to use the Numpy function np.nan_to_num() on the data before returning it from the python script
I have a Lambda function which calls a Python script, which in turn gives results in json format.
There is a possibility for the results of the script to tend to infinity, and we end up with "inf" values in the json. When this happens, the script can run locally, but encounters an error when run in Lambda:
botocore.errorfactory.InvalidRequestContentException: An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Could not parse payload into json: Non-standard token 'Infinity': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow at... 
among the results when run locally, I do see:
0.008559854691925183, inf, inf, inf, 0.0011680872601948522
It seems to be telling me to enable this feature of the json parser.... I have no idea how to do that. I have checked around and I see people running into a similar json error in different contexts,but found no examples for AWS/Python. Are there a couple lines I can add to my Lambda function to ignore the error?
Alternatively, maybe "inf" should just be replaced by the largest possible float value, or something like that?
The plotting of these results is handled by a separate lambda function, so it would be enough to shuttle the results along and handle the infinite value there, but the mere presence of this non-numeric value seems to throw a wrench in the gears. How would you handle this? Thanks.
Handling infinite values in returned JSON in AWS Lambda Python function