text_html_output_1.png
import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data = pd.read_csv('/kaggle/input/adult-census-income/adult.csv', na_values='?')

data.shape

data.columns = ['age', 'workclass', 'fnlwgt', 'education', 'education_num', 'marital_status', 'occupation', 'relationship', 'race', 'sex', 'capital_gain', 'capital_loss', 'hours_per_week', 'native_country', 'income']

data.isna().sum()

data = data.replace({'<=50K': 0, '>50K': 1})
data = data.replace({'<=50K': 0, '>50K': 1})

list_columns = []
list_categorical_col = []
list_numerical_col = []

def get_col(df: 'dataframe', type_descr: 'numpy') -> list:
    """
    Function get list columns 
    
    Args:
    type_descr
        np.number, np.object -> return list with all columns
        np.number            -> return list numerical columns 
        np.object            -> return list object columns
    """
    try:
        col = (df.describe(include=type_descr).columns)  # pandas.core.indexes.base.Index  
    except ValueError:
        print(f'Dataframe not contains {type_descr} columns !', end='\n')    
    else:
        return col.tolist()

list_numerical_col = get_col(df=data, type_descr=np.number)
list_categorical_col = get_col(df=data, type_descr=np.object)
list_columns = get_col(df=data, type_descr=[np.object, np.number])

list_numerical_col