ts_shape.transform.calculator.numeric_calc
| Name | Description |
|---|---|
IntegerCalc | Provides class methods for performing calculations on integer columns in a pandas DataFrame. |
IntegerCalc
Bases: Base
Provides class methods for performing calculations on integer columns in a pandas DataFrame.
| Name | Description |
|---|---|
scale_column | Scales the integer column by the given factor. |
offset_column | Offsets the integer column by the given value. |
divide_column | Divides each value in the integer column by the given divisor. |
subtract_column | Subtracts a given value from each element in the integer column. |
calculate_with_fixed_factors | Performs a calculation by multiplying with a factor and then adding an additional factor. |
mod_column | Performs a modulus operation on the integer column with a specified value. |
power_column | Raises each value in the integer column to the power of a specified value. |
scale_column
scale_column(
dataframe: pd.DataFrame,
value_column: str = "value_integer",
factor: float = 1,
) -> pd.DataFrame
Scales the integer column by the given factor.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame to perform the operation on. | required |
value_column | str | The column to apply the scaling to. | 'value_integer' |
factor | float | The scaling factor. | 1 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: The DataFrame with the scaled column. |
offset_column
offset_column(
dataframe: pd.DataFrame,
value_column: str = "value_integer",
offset_value: float = 0,
) -> pd.DataFrame
Offsets the integer column by the given value.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame to perform the operation on. | required |
value_column | str | The column to apply the offset to. | 'value_integer' |
offset_value | float | The value to add (positive) or subtract (negative) from each element in the column. | 0 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: The DataFrame with the offset column. |
divide_column
divide_column(
dataframe: pd.DataFrame,
value_column: str = "value_integer",
divisor: float = 1,
) -> pd.DataFrame
Divides each value in the integer column by the given divisor.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame to perform the operation on. | required |
value_column | str | The column to apply the division to. | 'value_integer' |
divisor | float | The value by which to divide each element. | 1 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: The DataFrame with the divided column. |
| Type | Description |
|---|---|
ValueError | If divisor is zero. |
subtract_column
subtract_column(
dataframe: pd.DataFrame,
value_column: str = "value_integer",
subtract_value: float = 0,
) -> pd.DataFrame
Subtracts a given value from each element in the integer column.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame to perform the operation on. | required |
value_column | str | The column to apply the subtraction to. | 'value_integer' |
subtract_value | float | The value to subtract from each element. | 0 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: The DataFrame with the subtracted column. |
calculate_with_fixed_factors
calculate_with_fixed_factors(
dataframe: pd.DataFrame,
value_column: str = "value_integer",
multiply_factor: float = 1,
add_factor: float = 0,
) -> pd.DataFrame
Performs a calculation by multiplying with a factor and then adding an additional factor.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame to perform the operation on. | required |
value_column | str | The column to apply the calculations to. | 'value_integer' |
multiply_factor | float | The factor to multiply each value by. Defaults to 1 (no scaling). | 1 |
add_factor | float | The value to add after multiplication. Defaults to 0 (no offset). | 0 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: The DataFrame after applying the calculations. |
mod_column
mod_column(
dataframe: pd.DataFrame,
value_column: str = "value_integer",
mod_value: int = 1,
) -> pd.DataFrame
Performs a modulus operation on the integer column with a specified value.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame to perform the operation on. | required |
value_column | str | The column to apply the modulus operation to. | 'value_integer' |
mod_value | int | The value to perform the modulus operation with. | 1 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: The DataFrame with the modulus operation applied. |
| Type | Description |
|---|---|
ValueError | If mod_value is zero. |
power_column
power_column(
dataframe: pd.DataFrame,
value_column: str = "value_integer",
power_value: float = 1,
) -> pd.DataFrame
Raises each value in the integer column to the power of a specified value.
An integer column stays integer only when the result is exact: a
non-negative whole exponent whose results all fit in int64. A
negative or fractional exponent, or a result beyond int64 (e.g.
10 ** 64), gives float64 values (numpy.float_power) instead
of wrapped-around integers or an error: [2, 3, 10] ** -1 is
[0.5, 0.333..., 0.1]. (A nullable Int64 column becomes
Float64, a pyarrow integer column double[pyarrow].) Other
columns use values ** power_value.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame to perform the operation on. | required |
value_column | str | The column to apply the power operation to. | 'value_integer' |
power_value | float | The exponent to raise each element to. | 1 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: The DataFrame with the power operation applied. |