Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS API for Python

Download the samples Try it live

Finding a New Home

Buying or selling of a house can be a very stressful event in one's life. The process could be frustrating as it is lengthy, uncertain and needs a lot of examination. Through this workflow we will guide a couple (Mark and Lisa) who is interested in selling their home and relocating to a place nearest to both of their work places. In this case study, we will explore the current housing market, estimate average house prices in their area and hunt for a new one. We will download the Zillow data for their current home for our analysis. You can use your own data and follow along with this workflow which aims to help Mark and Lisa in finding their new home.

The notebook is divided into two parts. In the first part, we will calculate the following:

  • Percentage of decrease/increase in house price since Mark and Lisa bought their home.
  • Suggested selling price for their home.
  • Whether their zip code is a buyer’s market or seller’s market.
  • Average number of days it takes for homes to sell in their neighbourhood.

In the second part of the notebook, we will explore the investment potential of homes close to their work places. Based on how much a person is willing to spend commuting to work, we will create a drive-time buffer. This will narrow down the search areas. Zillow also provides data for market health and projected home value appreciation. Visualizing the zip codes by their market health will help them focus only on areas with good market health. Hence they will get a list of areas to choose from, for buying their new home.

Selling your home

Determine an appropriate selling price

1) Download home sales time series data from Zillow at www.zillow.com/research/data.

Mark and Lisa have a 3-bedroom home, so we will select the ZHVI 3-Bedroom time-series ($) data set at the ZIP Code level.

2) Prepare the Excel data as follows:

a) Using Excel, open the .csv file.

Notice that the RegionName field has ZIP Codes as numbers (if we sort the RegionName field we will notice the ZIP Codes for Massachusetts, for example, don't have leading zeros; 01001 is 1001). Also, notice the median home value columns are named using the year and month. The first data available is for April 1996 (1996-04). b) Copy all the column headings and the one record with data for their ZIP Code to a new Excel sheet.

Apply a filter to the RegionName field. Mark and Lisa live in Crestline, California, so we will apply a filter for the 92325 ZIP Code.

c) Select (highlight) fields starting with the month and year when they bought their home and continuing to the last month and year column in the Excel table. So, for example, since Mark and Lisa bought their home in December 2007, they highlight the the two rows from column 2007-01 to column 2018-08.

d) Copy (press Ctrl+C) the selected data and paste it, along with the column headings, to a new Excel sheet using Paste Transposed (right-click in the first cell of the new sheet to see the paste options; select Paste Transposed). This gives two columns of data.

e) The first column has date values but only includes the year and month. In column C, create a proper date field.

  • Right-click column C and format the cells to be category date.
  • In the first cell of column C, enter the following formula: = DATEVALUE(CONCATENATE(A1, "-01"))
  • Drag the Autofill handle down to the last data cell in the column.

f) Insert a top row and type the column headings:

YYYYMM, Value, and date.

g) Rename the Excel sheet (probably called Sheet2 at present) something like AveSellingPrice and delete the other sheets (the first sheet contains a large amount of data that we won't be using further in the workflow).

Mark and Lisa named their price Excel sheet CrestlineAveSellingPrice.

h) Save this new sheet as an Excel workbook.

Mark and Lisa named their Excel file Crestline3BdrmAveSellingPrice.xlsx.

3) Connect to your ArcGIS Online organization.

In [1]:
from arcgis.gis import GIS
In [2]:
gis = GIS("https://geosaurus.maps.arcgis.com", "arcgis_python", "P@ssword123")
In [3]:
import pandas as pd
import matplotlib.pyplot as plt

4) Load the excel file for analysis.

In [4]:
file_name1 = 'Crestline3BdrmAveSellingPrice.xlsx' 
data1 = pd.read_excel(file_name1)
In [5]:
data1.head()
Out[5]:
YYYYMM value date
0 2007-01 291000 2007-01-01
1 2007-02 289000 2007-02-01
2 2007-03 287400 2007-03-01
3 2007-04 286100 2007-04-01
4 2007-05 284000 2007-05-01
In [6]:
data1.tail()
Out[6]:
YYYYMM value date
135 2018-04 252200 2018-04-01
136 2018-05 254000 2018-05-01
137 2018-06 254800 2018-06-01
138 2018-07 254900 2018-07-01
139 2018-08 254900 2018-08-01
In [7]:
data1.shape
Out[7]:
(140, 3)
In [8]:
data1[['year','month','day']] = data1.date.apply(lambda x: pd.Series(
    x.strftime("%Y,%m,%d").split(","))) # split date into year, month, day
In [9]:
data1.head()
Out[9]:
YYYYMM value date year month day
0 2007-01 291000 2007-01-01 2007 01 01
1 2007-02 289000 2007-02-01 2007 02 01
2 2007-03 287400 2007-03-01 2007 03 01
3 2007-04 286100 2007-04-01 2007 04 01
4 2007-05 284000 2007-05-01 2007 05 01
In [10]:
grpby_data1 = data1.groupby(['year']).mean()
In [11]:
type(grpby_data1)
Out[11]:
pandas.core.frame.DataFrame

5) We will Create a graph showing how average home prices have changed since they bought their home.

In [12]:
grpby_data1.reset_index(inplace=True)
In [13]:
grpby_data1.head()
Out[13]:
year value
0 2007 276616.666667
1 2008 221875.000000
2 2009 188391.666667
3 2010 176216.666667
4 2011 154766.666667
In [14]:
grpby_data1.value
Out[14]:
0     276616.666667
1     221875.000000
2     188391.666667
3     176216.666667
4     154766.666667
5     145158.333333
6     163741.666667
7     183975.000000
8     197133.333333
9     229566.666667
10    235966.666667
11    252025.000000
Name: value, dtype: float64
In [15]:
grpby_data1.year
Out[15]:
0     2007
1     2008
2     2009
3     2010
4     2011
5     2012
6     2013
7     2014
8     2015
9     2016
10    2017
11    2018
Name: year, dtype: object
In [16]:
plt.plot(grpby_data1.year, grpby_data1.value)
plt.title("average home prices (2007-2018)")
plt.xlabel("date")
plt.ylabel("average house price")
Out[16]:
Text(0,0.5,'average house price')

7) Determine an appropriate selling price based on home sales trends as follows:

a) Determine the current average selling price and the average selling price when they bought their home. Divide the current average price by the beginning average price to see how much homes in their ZIP Code have appreciated or depreciated. When Mark and Lisa bought their home in December of 2007, 3-bedroom homes were selling for \$276,617.

In [17]:
price_initial = grpby_data1.iloc[0]
In [18]:
price_initial
Out[18]:
year       2007
value    276617
Name: 0, dtype: object
In [19]:
price_current = grpby_data1.iloc[-1]
In [20]:
price_current
Out[20]:
year       2018
value    252025
Name: 11, dtype: object
In [21]:
house_worth = price_current.value / price_initial.value
In [22]:
house_worth
Out[22]:
0.9110983912755316

This indicates that homes in Crestline are only worth 91 percent of what they were at the end of 2007.

b) We can get a rough estimate of what their home is worth by summing what they paid for their home plus what they invested in it, and multiplying that sum by the ratio computed above. Mark and Lisa, for example, paid \$291,000 in 2007 and invested \\$100,000 in solid improvements (new kitchen, major landscaping, hardwood flooring, and so on). Multiplying (\$291,000 + \\$100,000) by 0.91 gives a rough suggested selling price of \$343,134.

In [23]:
(price_initial.value + 100000)*house_worth
Out[23]:
343134.83912755316

Get additional information about the local real estate market

If their home is part of a seller's market, they are more likely to get their asking price.

1) Download the Buyer-Seller Index data at the ZIP Code level from www.zillow.com/research/data. In Home Listings and Sales select data type as seller-buyer index and geography as zip codes.

2) Open the .csv file using Excel. Zillow reports ZIP Codes as numbers. We will need to pad the ZIP Code numbers with leading zeros so the Zillow data will link to the ArcGIS ZIP Code geometry.

Follow these steps:

a) Sort the RegionName column from smallest to largest so we will be able to see how the formula below works.

b) Name a new column in the Excel table zipstring.

c) In the first cell of the new column, enter the formula to pad each RegionName value with leading zeros, keeping the rightmost five characters: =RIGHT(CONCAT("00000",B2),5)

d) Drag the Autofill handle down to the last data cell in the column.

3) Load the excel file for analysis

In [24]:
file_name2 = 'BuyerSellerIndex.xlsx'
data2 = pd.read_excel(file_name2)
In [25]:
data2.head()
Out[25]:
RegionType RegionName State CBSA Title SizeRankCity SizeRankMetro PctPriceCut DaysOnMarket BuyerSellerIndex BuyerSellerIndexMetro zipstring
0 Zip 1001 MA Springfield, MA 8273 83 22.916667 81.0 6.190476 9.185083 1001
1 Zip 1002 MA Springfield, MA 6684 83 29.787234 94.0 10.000000 9.185083 1002
2 Zip 1007 MA Springfield, MA 9088 83 16.091954 83.0 2.857143 9.185083 1007
3 Zip 1013 MA Springfield, MA 7061 83 31.147541 76.5 8.333333 9.185083 1013
4 Zip 1020 MA Springfield, MA 5172 83 25.000000 73.0 3.809524 9.185083 1020
In [26]:
data2.dtypes
Out[26]:
RegionType                object
RegionName                 int64
State                     object
CBSA Title                object
SizeRankCity               int64
SizeRankMetro              int64
PctPriceCut              float64
DaysOnMarket             float64
BuyerSellerIndex         float64
BuyerSellerIndexMetro    float64
zipstring                  int64
dtype: object
In [27]:
data2.columns
Out[27]:
Index(['RegionType', 'RegionName', 'State', 'CBSA Title', 'SizeRankCity',
       'SizeRankMetro', 'PctPriceCut', 'DaysOnMarket', 'BuyerSellerIndex',
       'BuyerSellerIndexMetro', 'zipstring'],
      dtype='object')

4) Select BuyerSellerIndex, DaysOnMarket, zipstring fields

In [28]:
cols = ['BuyerSellerIndex', 'DaysOnMarket', 'zipstring']
In [29]:
selected_data2 = data2[cols]

5) Explore the data values as follows:

a) Sort on the DaysOnMarket field and notice the range. For the data Mark and Lisa downloaded, the range is 35 to 294.5 days.

In [30]:
days_on_mrkt_df = selected_data2.sort_values(by='DaysOnMarket', axis=0)
In [31]:
days_on_mrkt_df.DaysOnMarket.min()
Out[31]:
35.0
In [32]:
days_on_mrkt_df.DaysOnMarket.max()
Out[32]:
294.5
In [33]:
days_on_mrkt_df.head()
Out[33]:
BuyerSellerIndex DaysOnMarket zipstring
7420 1.120000 35.0 98107
7434 4.960000 35.0 98136
7097 0.526316 35.0 94022
7426 0.640000 35.0 98117
7399 0.080000 35.0 98043
In [34]:
days_on_mrkt_df.tail()
Out[34]:
BuyerSellerIndex DaysOnMarket zipstring
800 9.006849 252.0 8752
1177 10.000000 254.0 12428
1141 8.938356 261.5 11963
1189 9.160959 288.0 12545
753 6.000000 294.5 8403

b) Sort on the BuyerSellerIndex field and notice the range of values. ZIP Codes with index values near 0 are part of a strong seller's market; ZIP Codes with index values near 10 are part of a strong buyer's market.

In [35]:
buyer_seller_df = data2.sort_values(by='BuyerSellerIndex', axis=0)
In [36]:
buyer_seller_df.head()
Out[36]:
RegionType RegionName State CBSA Title SizeRankCity SizeRankMetro PctPriceCut DaysOnMarket BuyerSellerIndex BuyerSellerIndexMetro zipstring
517 Zip 7063 NJ New York-Newark-Jersey City, NY-NJ-PA 10423 1 4.687500 90.0 0.017123 9.585635 7063
4546 Zip 53168 WI Chicago-Naperville-Elgin, IL-IN-WI 10505 3 9.756098 59.5 0.033223 9.488950 53168
485 Zip 7004 NJ New York-Newark-Jersey City, NY-NJ-PA 10846 1 7.894737 92.0 0.034247 9.585635 7004
6572 Zip 90025 CA Los Angeles-Long Beach-Anaheim, CA 2122 2 6.451613 46.0 0.036364 4.185083 90025
1609 Zip 19152 PA Philadelphia-Camden-Wilmington, PA-NJ-DE-MD 4927 5 6.818182 67.0 0.041667 9.150552 19152
In [37]:
buyer_seller_df.tail()
Out[37]:
RegionType RegionName State CBSA Title SizeRankCity SizeRankMetro PctPriceCut DaysOnMarket BuyerSellerIndex BuyerSellerIndexMetro zipstring
6091 Zip 80016 CO Denver-Aurora-Lakewood, CO 2658 21 27.226891 62.0 10.0 4.502762 80016
4598 Zip 53954 WI Madison, WI 10773 87 21.875000 75.5 10.0 3.522099 53954
262 Zip 3049 NH Manchester-Nashua, NH 10693 131 28.787879 74.0 10.0 3.577348 3049
7321 Zip 97209 OR Portland-Vancouver-Hillsboro, OR-WA 4742 23 26.258993 78.5 10.0 5.096685 97209
1224 Zip 13104 NY Syracuse, NY 8916 79 28.323699 89.0 10.0 9.033149 13104
In [38]:
buyer_seller_df.BuyerSellerIndex.min()
Out[38]:
0.017123288
In [39]:
buyer_seller_df.BuyerSellerIndex.max()
Out[39]:
10.0

c) Filter the data to only show their home's ZIP code

In [40]:
selected_data2[selected_data2['zipstring'] == 92325]
Out[40]:
BuyerSellerIndex DaysOnMarket zipstring
6888 9.622642 79.0 92325

Notice the average number of days. Determine if the home is part of a buyer's or seller's market. Mark and Lisa learn that their home is part of a buyer's market (9.6), and they can expect their home to be on the market approximately 79 days before it sells.

In [41]:
selected_data2.rename(columns={"zipstring": "ZIP_CODE"}, inplace=True)
In [42]:
selected_data2.shape
Out[42]:
(7548, 3)
In [43]:
selected_data2.dtypes
Out[43]:
BuyerSellerIndex    float64
DaysOnMarket        float64
ZIP_CODE              int64
dtype: object
In [44]:
selected_data2 = slctd_data2.astype({"ZIP_CODE": int})
In [45]:
selected_data2.dtypes
Out[45]:
BuyerSellerIndex    float64
DaysOnMarket        float64
ZIP_CODE              int32
dtype: object

6) Search for the United States ZIP Code Boundaries 2017 layer. We can specify the owner's name to get more specific results. To search for content from the Living Atlas, or content shared by other users on ArcGIS Online, set outside_org=True

In [46]:
items = gis.content.search('United States ZIP Code Boundaries 2017',
                           outside_org=True)

Display the list of results.

In [47]:
from IPython.display import display

for item in items:
    display(item)
2017 Tapestry Segmentation in the United States
This map shows the dominant LifeMode Summary Group in the United States in 2017 by state, county, ZIP Code, tract, and block group based on Esri's Tapestry Segmentation system. ArcGIS Online subscription required.Web Map by esri
Last Modified: August 16, 2018
0 comments, 4,965 views
United States ZIP Code Boundaries 2017
This layer shows the ZIP Code level boundaries of United States in 2017. The boundaries are optimized to improve Data Enrichment analysis performance.Feature Layer Collection by esri_dm
Last Modified: June 29, 2018
0 comments, 22,804 views
USA ZIP Code Areas
This group layer presents five-digit ZIP Code areas used by the U.S. Postal Service to deliver mail more effectively. This detailed layer is approximately 315 MB compressed.Layer Package by esri_dm
Last Modified: April 11, 2018
48 comments, 1,02,810 views
2017 Median Household Income in the United States
This map shows the median household income in the U.S. in 2017 in a multiscale map by country, state, county, ZIP Code, tract, and block group. ArcGIS Online subscription required.Web Map by esri
Last Modified: August 16, 2018
0 comments, 1,904 views
bayAreaRENT
These files were specifically created to support small-scale thematic mapping. To improve the appearance of shapes at small scales, areas are represented with fewer vertices than detailed TIGER/Line Shapefiles. Cartographic boundary files take up less disk space than their ungeneralized counterparts. Cartographic boundary files take less time to render on screen than TIGER/Line Shapefiles. You can join this file with table data downloaded from American FactFinder by using the AFFGEOID field in the cartographic boundary file. If detailed boundaries are required, please use the TIGER/Line Shapefiles instead of the generalized cartographic boundary files.Feature Layer Collection by cfin2_pdxedu
Last Modified: June 07, 2018
0 comments, 16 views
Kentucky Diversity Index
This map summarizes racial and ethnic diversity in the Commonwealth of Kentucky in 2012.Web Map by kimberly.anness_kygeonet
Last Modified: April 29, 2015
0 comments, 105 views
2017 USA_Demographics_and_Boundaries Layer - Authenticated
This service offers Esri's Updated Demographics, Census Data, Tapestry Segmentation, and Business Summary data for the United States.Map Image Layer by esri_devlabs
Last Modified: January 24, 2018
0 comments, 249 views
Summarize_Drug_Mapping_Index_within_United_States_ZIP_Code_Boundaries_2017
Feature layer generated from Summarize WithinFeature Layer Collection by mijeong_sbu
Last Modified: October 18, 2018
0 comments, 61 views
USA Demographics
This service offers Esri's Updated Demographics, Census Data, Tapestry Segmentation, and Business Summary data for the United States.Map Image Layer by leslie.araujo_ColliersGIS
Last Modified: March 06, 2018
0 comments, 594 views
Join_Features_to_United_States_ZIP_Code_Boundaries_2017
Feature layer generated from Join FeaturesFeature Layer Collection by jbowles_statesales
Last Modified: July 04, 2018
0 comments, 42 views

Select the desired item from the list.

In [48]:
us_zip = items[1]
In [49]:
us_zip
Out[49]:
United States ZIP Code Boundaries 2017
This layer shows the ZIP Code level boundaries of United States in 2017. The boundaries are optimized to improve Data Enrichment analysis performance.Feature Layer Collection by esri_dm
Last Modified: June 29, 2018
0 comments, 22,804 views

Get the layer names from the item

In [50]:
for lyr in us_zip.layers:
    print(lyr.properties.name)
USA_Country
USA_State
USA_County
USA_ZipCode
USA_Tract
USA_BlockGroup

7) We want to merge the zip_code layer with data2 to visualize the result on the map.

In [51]:
us_zip_lyr = us_zip.layers[3]
In [52]:
zip_df = pd.DataFrame.spatial.from_layer(us_zip_lyr)
In [53]:
zip_df.head()
Out[53]:
OBJECTID POPULATION PO_NAME SHAPE SQMI STATE Shape__Area Shape__Length ZIP_CODE
0 178 -99 Puerto Real {"rings": [[[-65.6266549999283, 18.33133500021... 0.36 PR 0.000079 0.045943 00740
1 208 -99 San Juan {"rings": [[[-66.0720289997385, 18.44898199991... 0.51 PR 0.000113 0.072860 00909
2 209 -99 San Juan {"rings": [[[-66.0631219999803, 18.45542900044... 0.41 PR 0.000090 0.042467 00911
3 210 -99 San Juan {"rings": [[[-66.052898999789, 18.446785000227... 0.35 PR 0.000078 0.052902 00912
4 211 -99 San Juan {"rings": [[[-66.0382759999374, 18.45309599988... 0.39 PR 0.000086 0.046390 00913
In [54]:
zip_df.shape
Out[54]:
(30924, 9)
In [55]:
zip_df.dtypes
Out[55]:
OBJECTID            int64
POPULATION          int64
PO_NAME            object
SHAPE            geometry
SQMI              float64
STATE              object
Shape__Area       float64
Shape__Length     float64
ZIP_CODE           object
dtype: object
In [56]:
zip_df = zip_df.astype({"ZIP_CODE": int})
In [57]:
zip_df.dtypes
Out[57]:
OBJECTID            int64
POPULATION          int64
PO_NAME            object
SHAPE            geometry
SQMI              float64
STATE              object
Shape__Area       float64
Shape__Length     float64
ZIP_CODE            int32
dtype: object
In [58]:
merged_df = pd.merge(zip_df, selected_data2, on='ZIP_CODE')
In [59]:
merged_df
Out[59]:
OBJECTID POPULATION PO_NAME SHAPE SQMI STATE Shape__Area Shape__Length ZIP_CODE BuyerSellerIndex DaysOnMarket
0 2456 12455 Trenton {'rings': [[[-74.7233979997179, 40.22921699996... 0.84 NJ 0.000231 0.076210 8629 6.470588 130.0
1 2542 27090 New York {'rings': [[[-74.0010520003495, 40.75707400026... 0.65 NY 0.000178 0.072050 10001 9.212329 165.0
2 2544 57216 New York {'rings': [[[-73.9897530000009, 40.73915600044... 0.56 NY 0.000155 0.059765 10003 5.924658 118.5
3 2546 7393 New York {'rings': [[[-74.0094065996348, 40.70859879999... 0.07 NY 0.000019 0.021747 10005 5.856164 207.0
4 2550 29545 New York {'rings': [[[-73.9914120000637, 40.74479599973... 0.35 NY 0.000096 0.069161 10010 1.712329 121.0
5 2552 25320 New York {'rings': [[[-73.9918769999236, 40.72642499971... 0.32 NY 0.000088 0.045895 10012 8.544521 147.0
6 2554 31849 New York {'rings': [[[-74.0082101002159, 40.74212730023... 0.87 NY 0.000241 0.081262 10014 9.178082 155.0
7 2555 58179 New York {'rings': [[[-73.9818240003773, 40.75221199998... 0.55 NY 0.000151 0.056542 10016 8.613014 161.5
8 2556 16475 New York {'rings': [[[-73.9776450001166, 40.75790800005... 0.34 NY 0.000095 0.046537 10017 9.863014 172.0
9 2560 45429 New York {'rings': [[[-73.9651569997957, 40.77503200012... 0.36 NY 0.000098 0.052537 10021 6.404110 142.0
10 2561 34678 New York {'rings': [[[-73.9725316995782, 40.76492540008... 0.47 NY 0.000130 0.052119 10022 4.058219 131.0
11 2564 97723 New York {'rings': [[[-73.9647499999125, 40.80667099956... 0.93 NY 0.000258 0.081115 10025 8.835616 135.5
12 2565 35841 New York {'rings': [[[-73.9490600003187, 40.79711100027... 0.40 NY 0.000111 0.049993 10026 7.773973 142.0
13 2567 51952 New York {'rings': [[[-73.9471120004184, 40.77593100021... 0.37 NY 0.000102 0.057411 10028 3.767123 128.0
14 2575 26295 New York {'rings': [[[-73.9793569999256, 40.75781400021... 0.41 NY 0.000112 0.055149 10036 7.636986 160.0
15 2577 19254 New York {'rings': [[[-73.9975894000307, 40.71405899962... 0.27 NY 0.000074 0.050012 10038 8.630137 133.0
16 2581 34560 New York {'rings': [[[-73.9689039999196, 40.76987899991... 0.37 NY 0.000104 0.054014 10065 8.852740 163.0
17 2582 8069 New York {'rings': [[[-73.9854470001789, 40.77848200004... 0.07 NY 0.000020 0.023807 10069 8.407534 212.0
18 2583 25559 New York {'rings': [[[-73.9632269998261, 40.77768200002... 0.20 NY 0.000056 0.043360 10075 9.777397 169.0
19 2584 58132 New York {'rings': [[[-73.9380339999691, 40.78139400033... 0.41 NY 0.000112 0.057885 10128 3.886986 126.5
20 2585 4943 New York {'rings': [[[-74.0188334003411, 40.71385009970... 0.29 NY 0.000080 0.040173 10280 7.345890 167.0
21 2682 12212 White Plains {'rings': [[[-73.7552379996339, 41.03708100038... 0.61 NY 0.000169 0.063106 10601 3.544521 120.0
22 2755 13791 Glen Oaks {'rings': [[[-73.7136809996783, 40.75098400001... 0.85 NY 0.000236 0.074212 11004 4.349315 140.0
23 2789 39191 Brooklyn {'rings': [[[-73.972898999789, 40.688529000413... 0.77 NY 0.000213 0.072785 11217 7.928082 122.5
24 2832 70548 Jackson Heights {'rings': [[[-73.8693930001868, 40.74916000043... 0.73 NY 0.000201 0.069867 11372 4.914384 131.0
25 2834 45238 Rego Park {'rings': [[[-73.8551439995958, 40.73365000014... 0.91 NY 0.000250 0.081508 11374 1.763699 122.0
26 2844 20449 Kew Gardens {'rings': [[[-73.8259880004458, 40.71540799977... 0.60 NY 0.000166 0.065116 11415 2.859589 141.0
27 2848 49787 South Richmond Hill {'rings': [[[-73.8137580003314, 40.69719299975... 1.13 NY 0.000311 0.075217 11419 6.489726 174.5
28 2850 41352 Woodhaven {'rings': [[[-73.8480509998537, 40.69697499959... 0.89 NY 0.000246 0.075340 11421 5.068493 130.0
29 2855 20501 Queens Village {'rings': [[[-73.7315669998172, 40.72812499986... 0.78 NY 0.000213 0.070952 11428 9.571918 141.0
... ... ... ... ... ... ... ... ... ... ... ...
7517 7989 569 Corolla {'rings': [[[-75.8017350003699, 36.22339999961... 25.42 NC 0.006608 3.880190 27927 2.962963 86.0
7518 8817 10792 Saint Helena Island {'rings': [[[-80.5026639699936, 32.48615300655... 118.00 SC 0.029279 3.472351 29920 6.000000 195.0
7519 9634 28532 Crawfordville {'rings': [[[-84.194501042366, 30.099732041358... 354.18 FL 0.085928 3.448172 32327 6.333333 76.5
7520 9898 24241 Homestead {'rings': [[[-80.7381350000302, 24.90858199985... 244.02 FL 0.056666 4.205947 33034 2.183908 110.0
7521 10273 17937 Naples {'rings': [[[-81.4673070003178, 25.81768399961... 230.29 FL 0.053746 6.040363 34114 7.333333 149.0
7522 10333 8305 Crystal River {'rings': [[[-82.6568639874458, 28.90209788084... 43.61 FL 0.010457 4.638455 34429 3.333333 95.0
7523 10342 10584 Homosassa {'rings': [[[-82.6720129999999, 28.69428900043... 79.24 FL 0.018971 4.254390 34448 0.833333 92.0
7524 23575 9841 Huntsville {'rings': [[[-93.6883229999065, 36.29339899996... 370.76 AR 0.096114 2.992102 72740 4.736842 80.0
7525 25514 21840 Rockport {'rings': [[[-97.0400069998232, 27.93515299971... 243.83 TX 0.058007 8.188865 78382 0.769231 87.0
7526 25539 32472 Corpus Christi {'rings': [[[-97.2678989996391, 27.57598000007... 29.26 TX 0.006913 2.933893 78418 9.230769 99.5
7527 26292 6890 Florissant {'rings': [[[-105.218172073364, 38.64722597599... 329.11 CO 0.088376 3.019834 80816 8.000000 59.0
7528 26866 18033 Boise {'rings': [[[-115.230685000312, 44.09868599975... 1302.52 ID 0.376447 6.134894 83716 1.363636 46.0
7529 26943 11314 Grantsville {'rings': [[[-112.493393000087, 41.07673499982... 656.39 UT 0.181396 2.907552 84029 7.647059 61.0
7530 27222 37289 Florence {'rings': [[[-111.3479739996, 33.2059810000232... 775.66 AZ 0.193550 3.300642 85132 6.769231 70.0
7531 27295 61176 Buckeye {'rings': [[[-112.461481599596, 33.46255920034... 1144.38 AZ 0.286641 4.734392 85326 3.153846 59.0
7532 27337 9896 Wickenburg {'rings': [[[-112.823633000063, 34.08961599987... 954.37 AZ 0.240773 2.981528 85390 5.230769 115.0
7533 27475 19039 Prescott {'rings': [[[-112.915543000009, 35.05493800038... 1178.82 AZ 0.300493 4.212657 86305 7.857143 86.0
7534 27488 6389 Mayer {'rings': [[[-111.882087999761, 34.54639000019... 643.13 AZ 0.163190 2.932573 86333 10.000000 106.0
7535 27491 11895 Sedona {'rings': [[[-111.351251125336, 34.55623602867... 2232.64 AZ 0.568873 9.561294 86336 3.571429 92.0
7536 28429 28140 Twentynine Palms {'rings': [[[-115.738129999999, 34.54909199979... 1074.11 CA 0.272093 3.691296 92277 4.716981 87.0
7537 28678 8242 Frazier Park {'rings': [[[-118.943382978439, 34.55745601654... 652.65 CA 0.166551 2.862508 93225 8.750000 82.0
7538 28797 33523 Ridgecrest {'rings': [[[-117.378411769867, 34.93857812881... 3579.67 CA 0.923261 7.368096 93555 3.125000 76.0
7539 29124 52408 Hollister {'rings': [[[-120.876585960388, 36.60677099227... 601.29 CA 0.157366 3.360811 95023 9.473684 56.0
7540 29982 18811 Cottage Grove {'rings': [[[-123.182713999751, 43.87389800009... 345.20 OR 0.099822 2.859344 97424 5.833333 67.0
7541 30194 22426 Enumclaw {'rings': [[[-121.805309999557, 47.37899899990... 554.03 WA 0.170257 3.923956 98022 6.720000 49.0
7542 30333 16676 Buckley {'rings': [[[-122.113037000057, 47.22157300039... 522.69 WA 0.160040 3.031019 98321 9.440000 56.0
7543 30624 11804 Colville {'rings': [[[-117.525071000326, 49.00057599978... 752.91 WA 0.237993 3.817824 99114 5.833333 78.0
7544 30647 5035 Kettle Falls {'rings': [[[-118.01892979977, 49.000368000083... 374.25 WA 0.118591 3.148989 99141 3.750000 84.0
7545 30656 8665 Newport {'rings': [[[-117.073884999593, 48.52493599999... 432.57 WA 0.135600 3.369712 99156 7.291667 72.0
7546 30801 30170 Palmer {'rings': [[[-149.39160000014, 61.478318999722... 1815.61 AK 0.795068 7.155241 99645 0.769231 73.0

7547 rows × 11 columns

In [60]:
merged_df.shape
Out[60]:
(7547, 11)
In [61]:
merged_df.spatial.set_geometry('SHAPE')
In [62]:
mergd_lyr = gis.content.import_data(merged_df,
                                    title='MergedLayer',
                                    tags='datascience')

8) Create a map of the BuyerSellerIndex field using the following steps:

Visualize Results

In [63]:
m1 = gis.map('United States')
m1
Out[63]: