diff --git a/src/pypfilt/obs.py b/src/pypfilt/obs.py index b53eacd86efb37d8b537fd6cce0f4607caa0ed33..4ad9bb87226b0bed43eddb77b9f918839a5e979f 100644 --- a/src/pypfilt/obs.py +++ b/src/pypfilt/obs.py @@ -450,16 +450,11 @@ class Univariate(Obs): # Load the data table. fields = [io.time_field(time_col), (value_col, np.float64)] df = io.read_fields(time_scale, filename, fields) - # Rename the columns to 'time' and 'value'. - rename_to = { - time_col: 'time', - value_col: 'value', - } - new_names = tuple( - rename_to.get(name, name) for name in df.dtype.names - ) - df.dtype.names = new_names - return df + # Rename the columns to 'time' and 'value', and ensure that the dtype + # metadata is updated to reflect the renamed columns. + fields_out = [io.time_field('time'), ('value', np.float64)] + dtype_out = io.fields_dtype(time_scale, fields_out) + return df.astype(dtype_out) def row_into_obs(self, row): """