Improved performance by faster concat call for dataframe

This commit is contained in:
dario 2023-12-17 23:27:47 +01:00
parent 232fb50b3e
commit c19fa0127b

View File

@ -49,12 +49,12 @@ class Logger(Advanceable):
self.__idx = -1
def _on_step(self, _: float):
self.__df = pd.concat([self.__df, pd.Series().copy()], ignore_index=True)
self.__df = pd.concat([self.__df, pd.DataFrame()], ignore_index=True)
self.__idx += 1
self.__df.loc[self.__idx, 'time'] = self.get_time()
def _on_reset(self):
self.__df = pd.DataFrame.from_dict({'time': [self.get_time()]})
self.__df = pd.DataFrame.from_dict({'time': [self.get_time()]}).astype(np.float64)
def write(self, attrib: str, value: Any, domain: str = 'all'):
"""Writes a value to the logger.