0

With class definition of:

import pandas as pd

class ScoreDataManager:

    def __init__(self):
        self.frameColumns = ['Reference', 'Translation', 'METEOR', 'TER', 'BLEU']
        self._df = pd.DataFrame(columns=self.frameColumns)
        

    def add_row(self, ref, trans, meteor, ter, bleu):
        self._df.append({'Reference': ref, 'Translation': trans, 'METEOR': meteor, 'TER': ter, 'BLEU': bleu},
                        ignore_index=True)

    def show(self):
        print(self._df.head())

If I run:

x = ScoreDataManager()
x.add_row('abc', 'abcd', 0.9, 0.87, 0.901)
x.show()

I get:

Empty DataFrame
Columns: [Reference, Translation, METEOR, TER, BLEU]
Index: []

But I expect the dataframe to contain the appended row.

1 Answer 1

1

Unlike normal append(), the append() is not in-place. You have to store the output.

def add_row(self, ref, trans, meteor, ter, bleu):
        self._df=self._df.append({'Reference': ref, 'Translation': trans, 'METEOR': meteor, 'TER': ter, 'BLEU': bleu},
                        ignore_index=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.