text_plain_output_1.png
import pandas as pd

df = pd.read_csv('../input/chinas-population-by-gender-and-urbanrural/Chinas Population En.csv')

df.columns = ['year', 'total', 'male', 'female', 'urban', 'rural']
df.sort_values(by='year', ignore_index=True, inplace=True)

tmp_mask = df['total'] - df['male'] - df['female'] != 0
df[tmp_mask]

df.loc[tmp_mask, 'total'] = df.loc[tmp_mask, 'male'] + df.loc[tmp_mask, 'female']
print('Cases of nonconformity by gender: {}'.format(sum(df['total'] - df['male'] - df['female'])))