Skip to content

Commit

Permalink
Fixed bug due to newest version of Pandas
Browse files Browse the repository at this point in the history
With `pandas` 0.21.0, a `KeyError` is thrown because `peakutils`
indexing a dataframe instead of a NumPy array in `analysis.peak_find`.
This is fixed by explicitly converting the intensity column into a
NumPy array before handing off to `peakutils`.
  • Loading branch information
laserkelvin committed Mar 16, 2020
1 parent ec793fa commit 878df44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyspectools/spectra/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ def peak_find(spec_df: pd.DataFrame, freq_col="Frequency", int_col="Intensity",
Pandas dataframe containing the peaks frequency/intensity
"""
peak_indices = peakutils.indexes(
spec_df[int_col],
spec_df[int_col].to_numpy(),
thres=thres,
thres_abs=True,
min_dist=min_dist
)
frequencies = peakutils.interpolate(
x=spec_df[freq_col].values,
y=spec_df[int_col].values,
x=spec_df[freq_col].to_numpy(),
y=spec_df[int_col].to_numpy(),
ind=peak_indices,
width=11
)
Expand Down

0 comments on commit 878df44

Please sign in to comment.