Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions endaq/calc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import scipy.signal
import pint


def sample_spacing(
data: Union[np.ndarray, pd.DataFrame],
convert: typing.Literal[None, "to_seconds"] = "to_seconds",
Expand Down Expand Up @@ -150,17 +149,21 @@ def resample(df: pd.DataFrame, sample_rate: Optional[float] = None) -> pd.DataFr
df,
num_samples_after_resampling,
t=df.index.values.astype(np.float64),
)
)
resampled_time = pd.date_range(
df.iloc[0].name, df.iloc[-1].name,
periods=num_samples_after_resampling,
)

# Check for datetimes, if so localize
if 'datetime' in str(df.index.dtype):
df.index = df.index.tz_localize(None)

resampled_df = pd.DataFrame(
resampled_data,
index=resampled_time.astype(df.index.dtype),
index=(resampled_time),
columns=df.columns,
)
)

resampled_df.index.name = df.index.name

Expand Down