glidertools.utils.merge_dimensions
- glidertools.utils.merge_dimensions(df1, df2, interp_lim=3)
Merges variables measured at different time intervals. Glider data may be sampled at different time intervals, as is the case for primary CTD and SciCon data.
- Parameters:
df1 (pandas.DataFrame) – A dataframe indexed by datetime64 sampling times. Can have multiple columns. The index of this first dataframe will be preserved.
df2 (pandas.DataFrame) – A dataframe indexed by datetime64 sampling times. Can have multiple columns. This second dataframe will be interpolated linearly onto the first dataframe.
- Returns:
merged_df – The combined arrays interpolated onto the index of the first axis
- Return type:
pandas.DataFrame
- Raises:
Userwarning – If either one of the indicies are not datetime64 dtypes
Example
You can use the following code and alter it if you want more control
>>> df = pd.concat([df1, df2], sort=True, join='outer') >>> df = (df .sort_index() .interpolate(limit=interp_lim) .bfill(limit=interp_lim) .loc[df1.index] )