Skip to content

Instantly share code, notes, and snippets.

@khaerulumam42
Created April 23, 2019 00:03
Show Gist options
  • Save khaerulumam42/1927426aa2923bff87440d56dd422330 to your computer and use it in GitHub Desktop.
Save khaerulumam42/1927426aa2923bff87440d56dd422330 to your computer and use it in GitHub Desktop.
def dictkeys_from_value(dictio, value):
idx_val = list(dictio.values()).index(value)
return list(dictio.keys())[idx_val]
diff = {}
daftar_negara = []
daftar_perubahan = []
for i, code in enumerate(list(results.keys())):
# proses ke dataframe supaya lebih mudah untuk ditampilkan ke data
pd_data = pd.DataFrame.from_dict(results[code])
daftar_negara.append(dictkeys_from_value(country_codes, code))
daftar_perubahan.append(((list(pd_data['currency'])[0])-(list(pd_data['currency'])[-1]))/(list(pd_data['currency'])[0])*100)
diff["negara"] = daftar_negara
diff["perubahan"] = daftar_perubahan
diff_pd = pd.DataFrame.from_dict(diff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment