forked from Jcrimm/Mapping-Boston-Gentrification-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.py
32 lines (23 loc) · 718 Bytes
/
merge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 18 14:58:40 2022
@author: jerem
"""
#%% Initial set-up
import pandas as pd
import geopandas as gpd
#%% Read in data files
#read in demographic data
gent = pd.read_csv("gent_by_block_grp.csv",dtype={"GEOID":str})
#read in geographic data
boston = gpd.read_file("boston.gpkg",layer="master")
#%% Now merge the two datafiles together
merged = boston.merge(gent,
on="GEOID",
how="left",
validate="1:1",
indicator=True)
merged = merged.drop(columns="_merge")
#%% Write to geopackage and csv
merged.to_file("boston.gpkg",layer="gent",index=False)
merged.to_csv("boston_gent.csv")