ts_shape.transform.calculator.numeric_calc
¤
Classes:
-
IntegerCalc
–Provides class methods for performing calculations on integer columns in a pandas DataFrame.
IntegerCalc
¤
IntegerCalc(dataframe: DataFrame, column_name: str = 'systime')
Bases: Base
Provides class methods for performing calculations on integer columns in a pandas DataFrame.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to be processed.
-
column_name
¤str
, default:'systime'
) –The column to sort by. Default is 'systime'. If the column is not found or is not a time column, the class will attempt to detect other time columns.
Methods:
-
calculate_with_fixed_factors
–Performs a calculation by multiplying with a factor and then adding an additional factor.
-
divide_column
–Divides each value in the integer column by the given divisor.
-
get_dataframe
–Returns the processed DataFrame.
-
mod_column
–Performs a modulus operation on the integer column with a specified value.
-
offset_column
–Offsets the integer column by the given value.
-
power_column
–Raises each value in the integer column to the power of a specified value.
-
scale_column
–Scales the integer column by the given factor.
-
subtract_column
–Subtracts a given value from each element in the integer column.
Source code in src/ts_shape/utils/base.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
calculate_with_fixed_factors
classmethod
¤
calculate_with_fixed_factors(dataframe: DataFrame, column_name: str = 'value_integer', multiply_factor: float = 1, add_factor: float = 0) -> DataFrame
Performs a calculation by multiplying with a factor and then adding an additional factor.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to perform the operation on.
-
column_name
¤str
, default:'value_integer'
) –The column to apply the calculations to.
-
multiply_factor
¤float
, default:1
) –The factor to multiply each value by. Defaults to 1 (no scaling).
-
add_factor
¤float
, default:0
) –The value to add after multiplication. Defaults to 0 (no offset).
Returns:
-
DataFrame
–pd.DataFrame: The DataFrame after applying the calculations.
Source code in src/ts_shape/transform/calculator/numeric_calc.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
divide_column
classmethod
¤
divide_column(dataframe: DataFrame, column_name: str = 'value_integer', divisor: float = 1) -> DataFrame
Divides each value in the integer column by the given divisor.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to perform the operation on.
-
column_name
¤str
, default:'value_integer'
) –The column to apply the division to.
-
divisor
¤float
, default:1
) –The value by which to divide each element.
Returns:
-
DataFrame
–pd.DataFrame: The DataFrame with the divided column.
Source code in src/ts_shape/transform/calculator/numeric_calc.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
get_dataframe
¤
get_dataframe() -> DataFrame
Returns the processed DataFrame.
Source code in src/ts_shape/utils/base.py
34 35 36 |
|
mod_column
classmethod
¤
mod_column(dataframe: DataFrame, column_name: str = 'value_integer', mod_value: int = 1) -> DataFrame
Performs a modulus operation on the integer column with a specified value.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to perform the operation on.
-
column_name
¤str
, default:'value_integer'
) –The column to apply the modulus operation to.
-
mod_value
¤int
, default:1
) –The value to perform the modulus operation with.
Returns:
-
DataFrame
–pd.DataFrame: The DataFrame with the modulus operation applied.
Source code in src/ts_shape/transform/calculator/numeric_calc.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
offset_column
classmethod
¤
offset_column(dataframe: DataFrame, column_name: str = 'value_integer', offset_value: float = 0) -> DataFrame
Offsets the integer column by the given value.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to perform the operation on.
-
column_name
¤str
, default:'value_integer'
) –The column to apply the offset to.
-
offset_value
¤float
, default:0
) –The value to add (positive) or subtract (negative) from each element in the column.
Returns:
-
DataFrame
–pd.DataFrame: The DataFrame with the offset column.
Source code in src/ts_shape/transform/calculator/numeric_calc.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
power_column
classmethod
¤
power_column(dataframe: DataFrame, column_name: str = 'value_integer', power_value: float = 1) -> DataFrame
Raises each value in the integer column to the power of a specified value.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to perform the operation on.
-
column_name
¤str
, default:'value_integer'
) –The column to apply the power operation to.
-
power_value
¤float
, default:1
) –The exponent to raise each element to.
Returns:
-
DataFrame
–pd.DataFrame: The DataFrame with the power operation applied.
Source code in src/ts_shape/transform/calculator/numeric_calc.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
scale_column
classmethod
¤
scale_column(dataframe: DataFrame, column_name: str = 'value_integer', factor: float = 1) -> DataFrame
Scales the integer column by the given factor.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to perform the operation on.
-
column_name
¤str
, default:'value_integer'
) –The column to apply the scaling to.
-
factor
¤float
, default:1
) –The scaling factor.
Returns:
-
DataFrame
–pd.DataFrame: The DataFrame with the scaled column.
Source code in src/ts_shape/transform/calculator/numeric_calc.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
subtract_column
classmethod
¤
subtract_column(dataframe: DataFrame, column_name: str = 'value_integer', subtract_value: float = 0) -> DataFrame
Subtracts a given value from each element in the integer column.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to perform the operation on.
-
column_name
¤str
, default:'value_integer'
) –The column to apply the subtraction to.
-
subtract_value
¤float
, default:0
) –The value to subtract from each element.
Returns:
-
DataFrame
–pd.DataFrame: The DataFrame with the subtracted column.
Source code in src/ts_shape/transform/calculator/numeric_calc.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|