Code1161 — Week 13

Tom W
Design Computing
Published in
1 min readJun 13, 2017

Apply —

A big magic thing that pandas has, allows you to do things quickly.

Sort of like a map, applied to an axis in a dataframe.

Gives you back a series

Can add a new column

Pets[“do”] = Pets.apply(action, axis=1)

Will ad a new column to pets called “do””

Row.geometry.centroid will return a centroid of the polygon geometry, from shapely library

Returns a point

Burbs[“distance_from_unsw”] = burbs.geometry.distamce…

Will return a distance as a new column, Euclidian in latlongs(?), not kms

Geometry.convex_hull.plot()

Gets convex hulls

Geometry.envelope

Gets an envelope

Ways to check for an intersection:

- draw a circle — gives a radius, if distance is greater than the two intersections, can’t be intersecting

-maybe bounding box

- convex hull

(always work from the least computing to the most)

Row.centroid.cords

Returns centroid points as a (x, y) coord

Polygon inclusion test

Draw a vector across from point, if it intersects an even number of times -> out, even -> in

within() — also works

-good opportunity to use a lambda

chloropleth — colouring in a map

eg. plot(column=”fsdhf”, cmap=”spring”)

--

--