Reputation: 8034
I asked previously the wrong question.
I have dataframe called df
it looks like this.
filename result
101 A
101 C
101 D
112 B
112 C
153 A
153 D
I have added this code to make in array format
results_df=df.groupby('filename')["result"].agg(list)
now results_df looks like this
101 [A,C,D]
112 [B,C]
153 [A,D]
But when I try to call each column separetly it does not work
I call filename using results_df["filename"]
i get error KeyError: 'filename'
I call result using results_df["result"]
i get error KeyError: 'result'
I tried renaming the dataframe but does not work
results_df.renamecolumns = ["filename","result" ]
Upvotes: 0
Views: 23
Reputation: 71687
Try this:
results_df = df.groupby('filename')["result"].agg(list).reset_index()
Now you should be able to call, results_df["filename"]
and results_df["result"]
.
Upvotes: 1