mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/SPATZ.git
synced 2025-12-16 17:28:04 +00:00
Performance increases by replacing "df.loc" by "df.at"
This commit is contained in:
@@ -199,18 +199,18 @@ class Dataset(Advanceable):
|
||||
float: Returns the requested value.
|
||||
"""
|
||||
if self.__interpolation == 'linear':
|
||||
t_min = self.__df['time'].iloc[self.__idx]
|
||||
t_max = self.__df['time'].iloc[self.__idx + 1]
|
||||
t_min = self.__df.at[self.__idx, 'time']
|
||||
t_max = self.__df.at[self.__idx + 1, 'time']
|
||||
|
||||
# Sometimes no time passes in-between two samples.
|
||||
if t_max == t_min:
|
||||
return self.__df[name].iloc[self.__idx]
|
||||
return self.__df.at[name, self.__idx]
|
||||
|
||||
# Compute the weight for interpolation.
|
||||
alpha = (self.get_time() - t_min) / (t_max - t_min)
|
||||
|
||||
# Interpolate linearly between the two data points.
|
||||
return (1 - alpha) * self.__df[name].iloc[self.__idx] + alpha * self.__df[name].iloc[self.__idx + 1]
|
||||
return (1 - alpha) * self.__df.at[self.__idx, name] + alpha * self.__df.at[self.__idx + 1, name]
|
||||
|
||||
def fetch_values(self, names: List[str]) -> np.array:
|
||||
"""Get specific values from the dataframe.
|
||||
|
||||
Reference in New Issue
Block a user