Using NumPy to replace Pandas GroupBy-Apply pattern for performance
Pandas UDF can be limited, so we can speed up the Pandas GroupBy-Apply pattern by using NumPy instead, resulting in a significant performance improvement. However, it's important to benchmark and consider costs before deciding between Pandas and NumPy for your specific use case...