Cannot read f1-score from csv file

Viewed 18

i am reading classification_report file after doing 10 fold cv

for i in _all_files:
    print(i)
    df = pd.read_csv(i)


    saved_column = df.f1-score
    a = saved_column[5]
    li.append(a)

I want to add f1-score and find mean. But I am getting below error:

AttributeError: 'DataFrame' object has no attribute 'f1'

I am able to fetch accuracy, precision and recall score using above code but bot f2-score.

2 Answers

Use:

saved_column = df['f1-score']

Hyphens are not allowed as part of an attribute name. That is, using the dot notation.

Maybe this way is necessary:

saved_column = df['f1-score']
a = saved_column.iloc[5]
Related