So i am reading a .xlsx file and i need to check how many variables in the xlsx file belong to each datatype in pandas and finally export it to excel.
So here is the code :
sheet = pd.read_excel(r"D:\Users\850034535\AnacondaProjects\Jupyter Project\Sample.xlsx",sheetname=2)
alldtypes = sheet.dtypes.value_counts()
alldtypes_df = list_of_all_variables.to_frame()
alldtypes_df.to_excel('123.xlsx')
This code gives an error: " TypeError: float() argument must be a string or a number, not 'numpy.dtype' "
So then i converted the dataframe to str type, so now an additional line of code was added :
alldtypes_df = alldtypes_df.applymap(str)
But still it is showing me the same error and the error given in the title.
Any suggestions would be much appreciated.
It seems need convert index to string
s:
alldtypes_df.index = alldtypes_df.index.astype(str)