Note to reassign the appended result back to the consolidating dataframe. The resulting code is: centroids_All = centroids_All.append(centroids_deno, ignore_index=True) I have no trouble running the whole code except the last line (saving result). ignore_index=True is added into the append() call so as to re-serialize the index. 1 I tried to save the result in excel, but I got the error - 'list' object has no attribute 'toexcel'. The code to append the DataFrame needs only slight change (by luck, similar syntax as your code to append list). It's almost complete, but I'm trying to output a few variables that I created in a code component into my data file for the experiment, and I haven't been able to figure out how to do that. This is to create an empty pandas DataFrame instead of empty list. 1 I'm working in PsychoPy to design an experiment. Simply change your code centroids_All = to: centroids_All = pd.DataFrame() Then use the resulting DataFrame object to call to_excel() Why do the output data have different headers This has made it difficult to combine all the data into one Excel file. You can use Dataframe.append() to append/concatenate your resulting DataFrame's within the loop instead of using list append. OS: Win10 PsychoPy version : v2022.2.5 What specifically went wrong when you tried that: Using the same version, eight experiments were designed with only variations in the experimental materials. Although you appended pandas Dataframe into the list centroids_All it still is not a pandas DataFrame by itself. However, the object centroids_All that you want to call the to_excel() function is defined as a list. The to_excel() function is defined under pandas objects and can be called by a pandas DataFrame object. I need to make a scoring function with the rating function that will output the results viewable to user and into excel or CSV or other file MichaelWood November 6, 2020, 4:01pm 1 OS (e.g. Kmeans = KMeans(n_jobs = -1, n_clusters = cluster, init='k-means++')Ĭounts = pd.om_dict(counts, orient='index', columns=)Ĭentroids_deno = pd.DataFrame(scaler.inverse_transform(kmeans.cluster_centers_),columns= df1.columns)Ĭentroids_deno = countsĬentroids_All.to_excel("centroidsAllResult.xlsx") I have no trouble running the whole code except the last line (saving result).Ĭan you help me spot the mistakes? Thank you from collections import Counterįrom sklearn.preprocessing import StandardScalerĭf1=pd.read_csv("Clus_readinFile.csv", index_col="Site_ID") I tried to save the result in excel, but I got the error - 'list' object has no attribute 'to_excel'.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |