text_plain_output_1.png image_output_1.png
from subprocess import check_output

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
from subprocess import check_output
print(check_output(['ls', '../input']).decode('utf8'))
def load_colls(load_dict, df):
    for item in load_dict:
        file_name = load_dict[item][0]
        entry = load_dict[item][1]
        index = load_dict[item][2]
        temp_dict = pd.read_csv(file_name, index_col=entry).to_dict()
        temp_dict = temp_dict[index]
        if entry == 'hs4%0':
            entry = 'hs4'
        df[item] = df[entry].map(temp_dict)
    return df
load_map = {'Country_name': ['../input/country_eng.csv', 'Country', 'Country_name'], 'hs2_name': ['../input/hs2_eng.csv', 'hs2', 'hs2_name'], 'hs4_name': ['../input/hs4_eng.csv', 'hs4%0', 'hs4_name'], 'hs6_name': ['../input/hs6_eng.csv', 'hs6', 'hs6_name'], 'hs9_name': ['../input/hs9_eng.csv', 'hs9', 'hs9_name']}
trade_hist = pd.read_csv('../input/year_1988_2015.csv')
trade_hist = load_colls(load_map, trade_hist)
trade_jpbg_hist = trade_hist[trade_hist['Country_name'] == 'Bulgaria']
trade_2016 = pd.read_csv('../input/ym_custom_2016.csv')
trade_2016 = load_colls(load_map, trade_2016)
trade_jpbg_2016 = trade_2016[trade_2016['Country_name'] == 'Bulgaria']