text_plain_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)

dataset = '/kaggle/input/adult-dataset/adult.csv'
dataset = pd.read_csv(dataset, header=None, sep=',\\s')
dataset.shape

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

categorical = [var for var in dataset.columns if dataset[var].dtype == 'O']

dataset.workclass.unique()

dataset.workclass.value_counts()

dataset['workclass'].replace('?', np.NaN, inplace=True)
dataset.workclass.value_counts()

dataset.occupation.unique()

dataset.occupation.value_counts()

dataset['occupation'].replace('?', np.NaN, inplace=True)
dataset.occupation.value_counts()

dataset.native_country.unique()

dataset.native_country.value_counts()

dataset['native_country'].replace('?', np.NaN, inplace=True)
dataset.native_country.value_counts()

numerical = [var for var in dataset.columns if dataset[var].dtype != 'O']
print('There are {} numerical variables\n'.format(len(numerical)))
print('The numerical variables are :', numerical)