Exporting Correlation Matrix (from function)
Don't use the matrix obtained from your function rather,

It looks like correlation is a DataFrame too, so you can simply use to_csv:

correlation_df(within your function itself).to_csv("C:\destinationfolder\file.csv")