I have to dataframes with the same columns. My task should be to subtract the df_tot from df_nap without touching the first column (\'A\'). What is the easiest solution for it?<
Set the common index for both dataframes before using pd.DataFrame.sub:
df_tot = df_tot.set_index('Wavelength')
df_nap = df_nap.set_index('Wavelength')
res = df_tot.sub(df_nap)
If you require 'Wavelength' as a series rather than an index, you can call reset_index on the result:
res = res.reset_index()
However, there are certain benefits attached to storing a unique row-identifier as an index rather than a series. For example, more efficient lookup and merge functionality.