Source code for libpyhat.transform.multiply_vector

# this function multiplies all the spectra in a data frame by a vector.
import numpy as np
import pandas as pd


[docs] def multiply_vector(df, vector, spect_label="wvl"): # TODO: Account for when the user sliced out intensities before calling function. df_spectra = df[spect_label] # Check to see if the user provided a path to a vector or a vector in a dataframe if not isinstance(vector, pd.DataFrame): vector = np.array(pd.read_csv(vector, sep=",", header=None))[:, 1] # Check that there are the same number of wavelengths # TODO: Check that the wavelengths match if df_spectra.shape[1] == vector.shape[0]: df[spect_label] = df_spectra.multiply(vector, axis=1) else: print("Vector is not the same size as the spectra!") return None return df