title: Is there a python package that supports Min-Max and Sum scaling of a data sample?
body: <p>I've been looking for a python package/command that is able to scale a given data sample with a predefined min, max and total sum for the to-be scaled sample. I've attempted to use the MinMaxScaler() function of the sklearn.preprocessing package as in the example underneath.</p>
  <p>Given a base sample:</p>
  <pre><code>from sklearn.preprocessing import MinMaxScaler
  import pandas as pd
  
  base_sample = pd.DataFrame([5 , 20 , 30 , 35, 45 , 60])
  
  sample_min = 10
  sample_max = 50
  
  scaler = MinMaxScaler(feature_range = (sample_min , sample_max))
          
  scaled_sample = scaler.fit_transform(base_sample)
  
  print(scaled_sample)
  </code></pre>
  <p>Producing:</p>
  <pre><code>[[10.        ]
   [20.90909091]
   [28.18181818]
   [31.81818182]
   [39.09090909]
   [50.        ]]
  </code></pre>
  <p>With Sum:</p>
  <pre><code>print(scaled_sample.sum())
  180.0
  </code></pre>
  <p>Yet what I need is a command that is able to do the above yet with a predefined different sum, for example based on the sum of the original sample:</p>
  <pre><code>print(base_sample.sum())
  195
  </code></pre>
  <p>or any other predefined sum. In essence the values inbetween the min and max have to be scaled accordingly to match the sum without violating the min and max constraints. I've been doing this kind of exercise for a long time within a commercial tool that unfortunately does not allow me to have a look under the hood for the underlying formulation. Any suggestions on how to proceed would be very welcome.</p>