Hi,
I am trying to analyze economic freedom index from https://www.heritage.org/index/about
I have written following code and want to export everything to excel where i am supposed to use tableau for creating charts (currently we are not using TabPy as we have been asked not to use it.
We are to export all the functions like data.head(), mean, median, mode, corr, et al in to excel and submit the project. Unfortunately, we are unable to do this as it says that DataFrame objects are mutable and hence, they cannot be hashed. Anyone has an idea on how we can clear this dataframe TypeError?
I am trying to analyze economic freedom index from https://www.heritage.org/index/about
I have written following code and want to export everything to excel where i am supposed to use tableau for creating charts (currently we are not using TabPy as we have been asked not to use it.
We are to export all the functions like data.head(), mean, median, mode, corr, et al in to excel and submit the project. Unfortunately, we are unable to do this as it says that DataFrame objects are mutable and hence, they cannot be hashed. Anyone has an idea on how we can clear this dataframe TypeError?
import pandas as pd import os os.chdir(r"D:\Documents\NJCU\Intro to Data Science\Final Project\the-economic-freedom-index") data = pd.read_csv("economicfreedom.csv",encoding='latin-1') data.columns = [c.replace(' ', '_') for c in data.columns] data.columns = [c.replace("'", '') for c in data.columns] print(data.head()) data.info().to_excel('Economic Index Analysis.xlsx', sheet_name='Data Info') info_dict = {data.head()} datinfo_write = pd.DataFrame({info_dict}) datinfo_writer = pd.ExcelWriter('Economic Index Analysis.xlsx',engine='xlswriter') datinfo_write.to_excel(datinfo_writer,sheet_name='Data Info')
Error:TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed