The memory requirements can shoot up if there are many unique values. Always check memory usage using the memory_usage() method before and after using pivot.