# Why is Dataset upset by division by zero?

Consider this example:

ds = Dataset @ Transpose[<|"a" -> {1, 2, 3, 4, 3, 2, 1}, "b" -> {6, 5, 4, 3, 2, 1, 0}|>,


Now say I need to work with the ratios of these two values. This works fine:

ds[;;-2, #a/#b &]


But this fails:

ds[All, #a/#b &]


It would be easier for me to just get a result with some ComplexInfinities. Does the operation fail by desgin or oversight? Is there a workaround? Should I just use

ds[All, Quiet[#a/#b] &]


all the time or is there a more general solution? Off[General::infy] doesn't prevent this from failing, though the failure message can't be displayed properly.

• I'd upvote this if it weren't deleted. :^) – Mr.Wizard Aug 4 '14 at 21:53
• @Mr.Wizard Undeleted because I just discovered FailureAction. – Szabolcs Aug 4 '14 at 21:55
• Post it! :-) .. – Mr.Wizard Aug 4 '14 at 21:56

One possible solution is using Quiet:

ds[All, Quiet[#a/#b]&]


Another possible solution is using the FailureAction option:

ds[All, #a/#b, FailureAction -> None]

• Why CW? Seems like a good self-answer to me. shrug – Mr.Wizard Aug 4 '14 at 21:57
• I'll delete this if someone writes a comprehensive answer. Just collecting here what I find as I progress ... – Szabolcs Aug 4 '14 at 21:57
• @Mr.Wizard I don't want to discourage other answers. I'm just learning to use Dataset. I didn't need to use it before. Now I have a good application. – Szabolcs Aug 4 '14 at 21:57
• I think FailureAction is your best option here. – rcollyer Aug 5 '14 at 1:32