Skip to content

Commit 43d6f85

Browse files
committed
Create make_country_to_continent.py
1 parent d62da57 commit 43d6f85

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pandas as pd
2+
3+
def read_data(path):
4+
5+
countries = pd.read_csv(f'{path}/continents.csv')
6+
coordinates = pd.read_csv(f'{path}/coordinates.csv')
7+
8+
return (countries,coordinates)
9+
10+
def get_ctry_to_cont(ctry, coord):
11+
12+
df = pd.merge(coord, ctry, how='left', on='Country')
13+
df = df.dropna()
14+
15+
return df
16+
17+
def make_country_to_continent(in_path, out_path):
18+
19+
ctry, coord = read_data(path=in_path)
20+
df = get_ctry_to_cont(ctry=ctry, coord=coord)
21+
22+
df.to_csv(f'{out_path}/country_to_continent.csv', index=False)
23+
24+
if __name__ == '__main__':
25+
26+
in_path = './data/processed'
27+
out_path = './data/processed'
28+
29+
make_country_to_continent(in_path=in_path,
30+
out_path=out_path)

0 commit comments

Comments
 (0)