Created
April 23, 2019 00:03
-
-
Save khaerulumam42/1927426aa2923bff87440d56dd422330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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