creative data analysis with python

20
Creative Data Analysis with Python Grant Paton-Simpson Senior Data & Implementation Specialist Optima Corporation Creator of SOFA Statistics

Upload: grant-paton-simpson

Post on 20-Aug-2015

604 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: Creative Data Analysis with Python

Creative Data Analysiswith Python

Grant Paton-Simpson

Senior Data & Implementation Specialist Optima Corporation

Creator of SOFA Statistics

Page 2: Creative Data Analysis with Python

Great Python Tools Available● Matplotlib (see Creating Interactive Applications in

Matplotlib by Jake Vanderplas http://vimeo.com/63260224)● Numpy● Python sets, ordered dicts, named tuples● PANDAS● SQL Alchemy, adodbapi, dbapi● Easy text processing

(e.g. HTML)● CSV● Python!

Page 3: Creative Data Analysis with Python

Get Inspired!

Page 4: Creative Data Analysis with Python

Flexibility

Page 5: Creative Data Analysis with Python

Use Freedom Responsibly!

See http://blog.revolutionanalytics.com/2010/04/when-infographics-go-bad.html etcand http://www.netmagazine.com/features/seven-dirty-secrets-data-visualisation

Page 6: Creative Data Analysis with Python

The point is in there somewhere – honest!

Page 7: Creative Data Analysis with Python

Simple can be best

Page 8: Creative Data Analysis with Python

Make a Simple Point● Make complex things simple● Extract small information from large data● Present truth, do not deceive

http://www.dataists.com/2010/10/...… what-data-visualization-should-do-simple-small-truth/

Page 9: Creative Data Analysis with Python

Make it easy for the audience

Page 10: Creative Data Analysis with Python

Flexible analysis needs flexible tools

Page 11: Creative Data Analysis with Python

Matplotlib can do it

Page 12: Creative Data Analysis with Python

is your friend

● How to shift a legend outside the plot

● How to have a major and minor axis

● How to shift x axis labels to the middle of a bar

● How to position a triangle a certain percentage along the x axis

● How to apply a heat map to circles etc etc

Page 13: Creative Data Analysis with Python

Annotations, layers, shape placement and much more!

Page 14: Creative Data Analysis with Python

Example with Percentile Lines

Page 15: Creative Data Analysis with Python

Iterate

Page 16: Creative Data Analysis with Python

Colour adds meaning

Page 17: Creative Data Analysis with Python

SQLThe power of ...

● Planned non-obsolescence

● Nothing you can't do

● Scales

● Can decouple

● SQL Alchemy, dbapi, adodbapi etc● In my current role, I use SQL with safe data where there is no

significant potential for dangerous input. In this case, the most readable and maintainable way of building SQL strings is to use dicts and string interpolation: “SELECT %(fld1)s, %(fld2)s FROM ...” % {“fld1”: dest_arrive_time, “fld2”: dest_depart_time}.But this is not a good habit otherwise – search on “SQL injection” if you don't know why!

● Read data using dicts: row[“dest_x”]

Page 18: Creative Data Analysis with Python

dbapi● con = db.connect(host=...)● cur = con.cursor()● sql = “SELECT fname

FROM data WHERE age > 40”

● cur.execute(sql)● print(“, ”.join(x[“fname”] for x in cur.fetchall()))

Page 19: Creative Data Analysis with Python

HTMLThe power of ...

● Text

● Nothing you can't do

● Easy to display tabular data, hyperlinks, subreports

● Clean HTML can be opened as documents and spreadsheets

● Conditional highlighting e.g. class_str = “class = 'highlight'

if age > 10 else ””

html.append(“<td %(class_str)s>%(age_val)</td>”)

Page 20: Creative Data Analysis with Python

Imagine, create, iterate ...