neptoon.data_prep
smoothing¶
Classes:
Functions:
SmoothData ¶
SmoothData(data, column_to_smooth, smooth_method='rolling_mean', window='12h', min_proportion_good_data=0.7, poly_order=None, auto_update_final_col=True)
A class for smoothing data using a variety of different methods.
This class provides functionality to smooth time series data using different methods such as rolling mean and Savitzky-Golay filter. It supports both count-based and time-based windows for the rolling mean method.
Attributes for SmoothData
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Data to be smoothed - must be time indexed |
required |
column_to_smooth
|
str
|
The column name of the column to be smoothed. |
required |
smooth_method
|
(Literal['rolling_mean', 'savitsky_golay'],)
|
The smooth method to apply, by default "rolling_mean" |
'rolling_mean'
|
window
|
str
|
The window size for smoothing. Time based str value e.g., 30m, 1h, 6h, 1d by default 24h. Converted to timedelta for use in smoothing. |
'12h'
|
min_proportion_good_data
|
float
|
The minimum proportion of available data in the window for a average to be taken, provided as a decimal. |
0.7
|
poly_order
|
Optional[int]
|
Poly order to apply (savitsky golay only), by default None |
None
|
auto_update_final_col
|
bool
|
Whether to update the ColumnInfo object to represent the new column as _FINAL, by default True |
True
|
create_new_column_name ¶
Creates a new column name based on the supplied column_to_smooth name. This depends on method and parameters used.
Returns:
| Type | Description |
|---|---|
str
|
New column name |
apply_smoothing ¶
Function to apply smoothing to a Series of data. It is presumed that the appropriate attributes have been assigned already.
Returns:
| Type | Description |
|---|---|
Series
|
The smoothed Series |