text_plain_output_1.png
import matplotlib.pyplot as plt

import os

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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from warnings import filterwarnings as filt
from scipy.stats import skew, norm
pd.options.display.max_columns = None
filt('ignore')
plt.style.use('fivethirtyeight')
plt.rcParams['figure.figsize'] = (12, 6)
import os

df = pd.read_csv('/kaggle/input/adult-census-income/adult.csv')
df.shape

df.columns = [c.replace('.', '_') for c in df.columns]

df.nunique()

df.isnull().values.sum()

df.workclass.unique()

df.occupation.unique()

def null_idx(df):
    idx = []
    for col in df.columns:
        i = df[df[col] == '?'].index.values.tolist()
        idx.append(i)
    return idx
def null_col(df, null_idx=None):
    if null_idx:
        n = pd.DataFrame({'null': [len(i) for i in null_idx], 'null_per': [len(i) / df.shape[0] for i in null_idx]}, index=df.columns).sort_values('null', ascending=False)
        return n[n.null > 0]
    n = pd.DataFrame(df.isnull().sum(), columns=['nans'])
    return n[n.nans > 0]

df[df.workclass == '?'].describe()