title: What exactly does the Scipy: signal.detrend (type='constant' ) do a time series data set and can I reverse signal.detrend in python?
body: <p>I am currently trying to model a Multivariate Random Forest on time series data. The only way I get decent test accuracies on the model is to detrend the data before modelling using the scipy detrend type=constant (the type=linear does not give good accuracies) with the following code:</p>
  
  <p><code>detrended =signal.detrend(feature, axis=-1, type='constant', bp=0, overwrite_data=True)</code></p>
  
  <p>After I model the data I want to show the results of the model as the original units before detrending. </p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li>Is there a way to reverse signal.detrend?</li>
  <li>What exactly does the signal.detrend (type=constant) do to the data? </li>
  </ol>
  
  <p>In the Scipy documentation I am aware of the following:</p>
  
  <p>type{‘linear’, ‘constant’}, optional
  The type of detrending. If type == 'linear' (default), the result of a linear least-squares fit to data is subtracted from data. If type == 'constant', only the mean of data is subtracted.</p>
  
  <p>However when I look at the data after performing signal.detrend (type=constat) it does not simply subtract the mean from the data as the documentation suggests. </p>
  
  <p>Any guidance on how to reverse the detrend function and what the detrend type=constant does to the data would be greatly appreciated.</p>