rescale_bands
rescale_bands(bands, to, from_=None)Move a band specification onto another scale.
The band presets are written on the scales survey work uses most: 1-5 for a rating, 0-10 for the Net Promoter answer, -100 to 100 for the score. Plenty of real questionnaires do not use those. rescale_bands() stretches a band specification onto the scale the chart is actually drawn on, so the thresholds stay where they are instead of the data being divided to meet them. The mapping is linear and proportional: a band covering the top fifth of its own scale covers the top fifth of the new one. Labels and colours are untouched.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bands | pandas.DataFrame | A band specification: one of the presets, or any data frame with from and to columns. |
required |
| to | list of float | The scale the chart uses, as [min, max]. |
required |
| from_ | list of float | The scale bands is written on. Read from the band edges when omitted, which is what you want for the presets. R names it from. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| pandas.DataFrame | bands with from and to moved onto the new scale. |
See Also
bands_rating_3, annotate_bands
Examples
>>> bands_rating_3().pipe(rescale_bands, to=[0, 100])
>>> bands_rating_3().pipe(rescale_bands, to=[1, 7])