Lter
Lter

Reputation: 55

Calculate the sum of the row values in a new dataframe

I have this type of dataframe which represents the label given by each annotator (column name) for a mention in a text (index):

enter image description here

My goal is to transform this view, to get the sum of the annotators for a label given at each mention of the text, as:

enter image description here

Will anyone have a lead for doing this? thanks in advance.

Upvotes: 0

Views: 34

Answers (1)

Nk03
Nk03

Reputation: 14949

IIUC, you can try:

df = df.set_index('<your date column name>').apply(pd.Series.value_counts, 1).fillna(0)

Upvotes: 2

Related Questions