watex.utils.findCatandNumFeatures#
- watex.utils.findCatandNumFeatures(df=None, features=None, return_frames=False)[source]#
Retrieve the categorial or numerical features on whole features of dataset.
- Parameters:
df (Dataframe) β Dataframe with columns composing the features
features (list of str,) β list of the column names. If the dataframe is big, can set the only required features. If features are provided, frame should be shrunked to match the only given features before the numerical and categorical features search. Note that an error will raises if any of one features is missing in the dataframe.
return_frames (bool,) β if set to
True, it returns two separated dataframes (cat & num) otherwise, it only returns the cat and num columns names.
- Returns:
Tuple
- Return type:
cat_features and num_features names or frames
Examples
>>> from watex.datasets import fetch_data >>>> from watex.tools import findCatandNumFeatures >>> data = fetch_data ('bagoue original').get('data=dfy2') >>> cat, num = findCatandNumFeatures(data) >>> cat, num ... (['type', 'geol', 'shape', 'name', 'flow'], ['num', 'east', 'north', 'power', 'magnitude', 'sfi', 'ohmS', 'lwi']) >>> cat, num = findCatandNumFeatures( data, features = ['geol', 'ohmS', 'sfi']) ... (['geol'], ['ohmS', 'sfi'])