Displaying a DataFrame in jupyter notebook


I am implementing a minimal learner class as suggested in lesson 4 :open_mouth: and I have a question related about displaying a pandas data frame at the end of each epoch.

How it’s possible to display additional rows without displaying all the dataframe? I noticed that the original learner don’t refresh the table, visually it’s like display the last row.

  def fit(self, num_epochs, lr):
    self.opt.lr = lr
    output = pd.DataFrame(index = np.arange(num_epochs),
                          columns = ['epoch', 'train_loss', 
                                     'valid_loss', 'metric', 'time'])
    for i in range(num_epochs):
      start = time.time()
      end = time.time()

      output.loc[i, 'time'] = end - start
      output.loc[i, 'epoch'] = i
      output.loc[i, 'train_loss'] = self.loss_values[i]
      output.loc[i, 'valid_loss'] = i
      output.loc[i, 'metric'] = self.validate_epoch(self.model)
      display_df(output.loc[:i, :]

I will appreciate any feedback :slight_smile: