Learn practical skills, build real-world projects, and advance your career
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv('adult_data.csv')
df.columns =['age','workclass', 'fnlwgt', 'education', 'education_num', 'marital_status', 'occupation',
             'relationship', 'race', 'sex', 'capital_gain', 'capital_loss', 'hours_per_week', 'native_country', 'salary']
df.head()
df.shape
(32561, 15)
def handle_capital_gain(df):
    df['capital_gain']= np.where(df['capital_gain']==0, np.nan, df['capital_gain'])
    df['capital_gain']= np.log(df['capital_gain'])
    df['capital_gain']= df['capital_gain'].replace(np.nan,0)