watex.utils.mlutils.exporttarget#

watex.utils.mlutils.exporttarget(df, tname, inplace=True)[source]#

Extract target and modified data in place or not .

Parameters:
  • df – A dataframe with features including the target name tname

  • tname – A target name. It should be include in the dataframe columns otherwise an error is raised.

  • inplace – modified the dataframe inplace. if False return the dataframe. the defaut is True

Returns:

Tuple of the target and dataframe (modified or not)

Example:

>>> from watex.datasets import fetch_data '
>>> from watex.utils.mlutils import exporttarget
>>> data0 = fetch_data ('bagoue original').get('data=dfy1')
>>> # no modification
>>> target, data_no = exporttarget (data0 , 'sfi', False )
>>> len(data_no.columns ) , len(data0.columns )
... (13, 13)
>>> # modified in place
>>> target, data= exporttarget (data0 , 'sfi')
>>> len(data.columns ) , len(data0.columns )
... (12, 12)