I\'m using Pandas pivot_table function on a large dataset (10 million rows, 6 columns). As execution time is paramount, I try to speed up the process. Currently it
Convert the columns months and industry to categorical columns:
https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html
This way you avoid a lot of string comparisons.