ddf.stainer.BinningStainer¶
-
class
ddf.stainer.
BinningStainer
(name='Binning', col_idx=[], group_size=None, n_groups=5, sf=4)¶ Stainer that bins continuous columns into discrete groups (each group represents an interval [a,b)).
-
__init__
(name='Binning', col_idx=[], group_size=None, n_groups=5, sf=4)¶ The constructor for BinningStainer class.
- Parameters
name (str, optional) – Name of stainer. Default is “Binning”.
col_idx (int list, optional) – Column indices that the stainer will operate on. Default is empty list.
group_size (int or None, optional) – Number of elements in each interval group. If None, then uses n_groups. Default is None.
n_groups (int, optional) – Number of interval groups to bin to. Ignored if group_size is not None. Default is 5.
sf (int) – Number of significant digits to be used in the output string representation for the intervals.
-
get_col_type
()¶ Returns the column type that the stainer operates on.
- Returns
Column type that the stainer operates on.
- Return type
string
-
get_history
()¶ Compiles history information for this stainer and returns it.
- Returns
name (str) – Name of stainer.
msg (str) – Message for user.
time (float) – Time taken to execute the self.transform() method.
-
get_indices
()¶ Returns the row indices and column indices.
- Returns
row_idx (int list) – Row indices that the stainer operates on.
col_idx (int list) – Column indices that the stainer operates on.
-
transform
(df, rng, row_idx=None, col_idx=None)¶ Applies staining on the given indices in the provided dataframe.
- Parameters
df (pd.DataFrame) – Dataframe to be transformed.
rng (np.random.BitGenerator) – PCG64 pseudo-random number generator.
row_idx (int list, optional) – Unused parameter as this stainer does not use row indices.
col_idx (int list, optional) – Column indices that the stainer will operate on. Will take priority over the class attribute col_idx.
- Returns
new_df (pd.DataFrame) – Modified dataframe.
row_map (empty dictionary) – This stainer does not produce any row mappings.
col_map (empty dictionary) – This stainer does not produce any column mappings.
-
update_history
(message='', time=0)¶ Used by transform method to set attributes required to display history information
- Parameters
message (str) – Mesasge to be shown to user about the transformation
time (float) – Time taken to perform the transform
Methods
__init__
([name, col_idx, group_size, …])The constructor for BinningStainer class.
Returns the column type that the stainer operates on.
Compiles history information for this stainer and returns it.
Returns the row indices and column indices.
transform
(df, rng[, row_idx, col_idx])Applies staining on the given indices in the provided dataframe.
update_history
([message, time])Used by transform method to set attributes required to display history information
-