-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89fc625
commit 0f224af
Showing
20 changed files
with
638,982 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "c0e537d0", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import geocoder\n", | ||
"import pandas as pd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "550510ff", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"keys = 'XAOoYswg87hHtrUL1JOq~iC_jT9iuSGb6pvBm-Xq76g~AifObMKF8shOCFYk33SvWKVznrEUPI925Sfco-cNrWXRjIBpcDfnLHSoB3yL6K_e'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "760e045e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# function for converting addresses to zipcodes\n", | ||
"def zipcode(i):\n", | ||
" g = geocoder.bing(i, key= keys)\n", | ||
" h = geocoder.bing([g.lat,g.lng], method ='reverse',key=keys)\n", | ||
" return h.postal" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "cfc3a3d3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"df = pd.read_excel('addresses.xlsx')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "79d38395", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div>\n", | ||
"<style scoped>\n", | ||
" .dataframe tbody tr th:only-of-type {\n", | ||
" vertical-align: middle;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe tbody tr th {\n", | ||
" vertical-align: top;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe thead th {\n", | ||
" text-align: right;\n", | ||
" }\n", | ||
"</style>\n", | ||
"<table border=\"1\" class=\"dataframe\">\n", | ||
" <thead>\n", | ||
" <tr style=\"text-align: right;\">\n", | ||
" <th></th>\n", | ||
" <th>address</th>\n", | ||
" <th>zipcode</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>0</th>\n", | ||
" <td>559 Ng Duy Trinh P. Binh Trung Dong, Tp. Thu D...</td>\n", | ||
" <td>NaN</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1</th>\n", | ||
" <td>Lý Tự Trọng, Bến Nghé, Quận 1, Thành phố Hồ Ch...</td>\n", | ||
" <td>NaN</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>2</th>\n", | ||
" <td>30-36 Đ. Phan Bội Châu, Phường Bến Thành, Quận...</td>\n", | ||
" <td>NaN</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"</div>" | ||
], | ||
"text/plain": [ | ||
" address zipcode\n", | ||
"0 559 Ng Duy Trinh P. Binh Trung Dong, Tp. Thu D... NaN\n", | ||
"1 Lý Tự Trọng, Bến Nghé, Quận 1, Thành phố Hồ Ch... NaN\n", | ||
"2 30-36 Đ. Phan Bội Châu, Phường Bến Thành, Quận... NaN" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"df.head()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "a059e123", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# populating zipcodes\n", | ||
"l=0\n", | ||
"for a,z in zip(df.address,df.zipcode):\n", | ||
" df.iloc[l,1]=zipcode(a)\n", | ||
" l+=1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "3d762623", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div>\n", | ||
"<style scoped>\n", | ||
" .dataframe tbody tr th:only-of-type {\n", | ||
" vertical-align: middle;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe tbody tr th {\n", | ||
" vertical-align: top;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe thead th {\n", | ||
" text-align: right;\n", | ||
" }\n", | ||
"</style>\n", | ||
"<table border=\"1\" class=\"dataframe\">\n", | ||
" <thead>\n", | ||
" <tr style=\"text-align: right;\">\n", | ||
" <th></th>\n", | ||
" <th>address</th>\n", | ||
" <th>zipcode</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>0</th>\n", | ||
" <td>559 Ng Duy Trinh P. Binh Trung Dong, Tp. Thu D...</td>\n", | ||
" <td>71006</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1</th>\n", | ||
" <td>Lý Tự Trọng, Bến Nghé, Quận 1, Thành phố Hồ Ch...</td>\n", | ||
" <td>71009</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>2</th>\n", | ||
" <td>30-36 Đ. Phan Bội Châu, Phường Bến Thành, Quận...</td>\n", | ||
" <td>71009</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"</div>" | ||
], | ||
"text/plain": [ | ||
" address zipcode\n", | ||
"0 559 Ng Duy Trinh P. Binh Trung Dong, Tp. Thu D... 71006\n", | ||
"1 Lý Tự Trọng, Bến Nghé, Quận 1, Thành phố Hồ Ch... 71009\n", | ||
"2 30-36 Đ. Phan Bội Châu, Phường Bến Thành, Quận... 71009" | ||
] | ||
}, | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"df" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "05b736bd", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.