You wrote a pandas script to compute a fee on 50 million credit card transactions: 3% for foreign transactions, 1% otherwise, using a row-wise apply. On a 16GB laptop it ran for two hours and then crashed with an out-of-memory error. How would you diagnose and fix this?