I have a dataframe with many rows and columns. One column - 'diagnostic superclass' has labels for every patient stored in rows as lists. It looks like this:
['MI', 'HYP', 'STTC']
['MI', 'CD', 'STTC']
I need to obtain a first label from every row The desired output is a column which stores every first list element of every row so I wrote a function:
def labels(column_with_lists):
label = column_with_lists
for a in column_with_lists() :
list_label = column_with_lists[0]
label = list_label[0]
return label
So when I run the code I face the following problem:
Traceback (most recent call last):
File "C:/Users/nikit/PycharmProjects/ECG/ECG.py", line 77, in <module>
print(labels(y_true['diagnostic_superclass']))
File "C:/Users/nikit/PycharmProjects/ECG/ECG.py", line 63, in labels
for a in column_with_lists() :
TypeError: 'Series' object is not callable