building rich high performance tools for prac7cal data
play

Building Rich, High Performance Tools for Prac7cal Data - PowerPoint PPT Presentation

Building Rich, High Performance Tools for Prac7cal Data Analysis Wes McKinney @wesmckinn Lambda Foundry, Inc. Talk Overview Background Goals Key Ingredients Examples My


  1. Building ¡Rich, ¡High ¡ Performance ¡Tools ¡for ¡ Prac7cal ¡Data ¡Analysis Wes ¡McKinney @wesmckinn Lambda ¡Foundry, ¡Inc.

  2. Talk ¡Overview  Background  Goals  Key ¡Ingredients  Examples

  3. My ¡Background  MIT ¡’07, ¡ ¡AQR ¡2007-­‑2010, ¡ ¡LF ¡2012-­‑ ¡  Lead ¡developer ¡of ¡pandas ¡ ¡(Python ¡library)

  4. Goals Data ¡Tooling

  5. Goals Big™ ¡and ¡Small™ ¡Data

  6. Goals Simplify ¡Data ¡Wrangling

  7. Goals User ¡interface ¡design

  8. User ¡interface ¡design i.e. ¡“how ¡do ¡I ¡do ¡what ¡ I ¡need?”

  9. API ¡Design

  10. API ¡Design  “Fits ¡your ¡brain”  “All ¡my ¡funcPons ¡have ¡17 ¡arguments”

  11. Syntax Matters

  12. API ¡Design (($:@(<#[),(=#[),$:@(>#[))({~ ?@#))^:(1<#) {f:*x@1?#x;:[0=#x;x;,/(_f x@&x<f;x@&x=f;_f x@&x>f)]} Text Text

  13. API ¡Design J (($:@(<#[),(=#[),$:@(>#[))({~ ?@#))^:(1<#) {f:*x@1?#x;:[0=#x;x;,/(_f x@&x<f;x@&x=f;_f x@&x>f)]} Text Text K/Kona

  14. API ¡Design >>>>>>>>,[>,]<[[>>>+<<<-]>[<+>-]<+<]>[<<<<<<<<+>>>>>>>>-]<<<<<<<<[[>>+ >+>>+<<<<<-]>>[<<+>>-]<[>+>>+>>+<<<<<-]>[<+>-]>>>>[-<->]+<[>->+<<-[>>- <<[-]]]>[<+>-]>[<<+>>-]<+<[->-<<[-]<[-]<<[-]<[[>+<-]<]>>[>]<+>>>>]>[-< <+[-[>+<-]<-[>+<-]>>>>>>>>[<<<<<<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<< -]>[<+>-]<+<]<[[>>>>>>>>+<<<<<<<<-]>>[<+>-]<+<<]>+>[<-<<[>+<-]<[<]>[[< +>-]>]>>>[<<<<+>>>>-]<<[<+>-]>>]<[-<<+>>]>>>]<<<<<<]>>>>>>>>>>>[.>]

  16. “A ¡user ¡interface ¡can ¡handle ¡only ¡so ¡ much ¡complexity ¡or ¡it ¡becomes ¡ unusable.” Guido ¡van ¡Rossum

  17. Key ¡Ingredients  API ¡/ ¡User ¡interface ¡design ¡  Data ¡types  Arrays  Data ¡structures  Efficient ¡Algorithms

  18. Arrays  Blob ¡of ¡bytes ¡as ¡mulPdimensional ¡array  All ¡elements ¡same ¡type  ImplementaPons: ¡NumPy ¡(Python), ¡J ¡/ ¡APL, ¡R, ¡MATLAB, ¡... Scalar Vector Matrix Cube/Hypercube Rank ¡0 Rank ¡1 Rank ¡2 Rank ¡> ¡2

  19. Arrays  Loopless ¡programming - ¡VectorizaPon - ¡BroadcasPng  No-­‑copy ¡views

  20. (Some) ¡Basic ¡data ¡types  Integer  FloaPng ¡point ¡/ ¡Complex  Characters ¡and ¡Strings ¡(ASCII ¡or ¡Unicode)  Date ¡and ¡Pme  Box ¡/ ¡“Object”

  21. (Some) ¡Basic ¡data ¡types  Integer  FloaPng ¡point ¡/ ¡Complex  Characters ¡and ¡Strings ¡(ASCII ¡or ¡Unicode)  Date ¡and ¡Pme  Box ¡/ ¡“Object”  Categorical ¡/ ¡enumeraPon ¡(R: ¡“factors”)  Record ¡or ¡structure ¡(one ¡or ¡more ¡of ¡the ¡above)

  22. Data ¡types Also, ¡any ¡values ¡can ¡be ¡“missing” ¡(NA) Text

  23. Risks  Stuck ¡in ¡type ¡soup generic number integer unsigned int signed int inexact floating complex character string_ unicode_ bool_ object_

  24. Risks  Actually ¡it’s ¡more ¡like integer unsigned int uint8 uint16 uint32 uint64 signed int int8 int16 int32 int64

  25. Data ¡types ¡and ¡users  Control ¡over ¡machine ¡representaPon - Treacherous, ¡but ¡oben ¡necessary  Simplicity ¡vs. ¡power ¡and ¡control

  26. Tables  A ¡sequence ¡of ¡arrays, ¡each ¡with ¡own ¡data ¡type 0 1 2 3 4 5

  27. Tables  A ¡sequence ¡of ¡arrays, ¡each ¡with ¡own ¡data ¡type  Common ¡simplificaPon: ¡only ¡1-­‑dimensional ¡arrays 0 1 2 3 4 5

  28. Table ¡and ¡Array ¡Axis ¡Labeling  One ¡or ¡more ¡categorical ¡arrays ¡per ¡axis  Numerous ¡uses 0 1 2 3 4 5 “Row labels” 1 2 A Text 3 4 1 2 B 3 4

  29. Table ¡and ¡Array ¡Axis ¡Labeling

  30. Table ¡and ¡Array ¡Axis ¡Labeling ....

  31. This ¡predicates ¡on ¡the ¡ existence ¡of ¡sane ¡APIs ¡

  32. Some ¡“primi7ve” ¡opera7ons  Align ¡/ ¡join ¡/ ¡merge ¡/ ¡“Vlookup”  Concatenate  Reshape, ¡Stack/fold, ¡Unstack/unfold, ¡Pivot, ¡Melt  Subset: ¡Drop ¡rows, ¡columns  Elementwise ¡transforms: ¡map, ¡replace, ¡fill, ¡string ¡stuff  Group ¡By: ¡Apply, ¡Aggregate, ¡Transform, ¡Cut, ¡...  Set ¡operaPons: ¡Unique, ¡deduplicate, ¡is-­‑in

  33. Example: ¡concatena7on leb ¡(prices) right ¡(volume)

  34. Example: ¡concatena7on result = concat([left, right], axis=1, keys=[‘price’, ‘volume’])

  35. Example: ¡stack/fold result.stack(0)

  36. Under ¡the ¡hood  Array ¡/ ¡vector ¡operaPons  Efficient ¡data ¡movement  Hash ¡sets ¡and ¡tables  SorPng ¡algorithms  RelaPonal ¡algebra

  37. Example: ¡group-­‑by  H. ¡Wickham ¡“The ¡Split-­‑Apply-­‑Combine ¡Strategy ¡for ¡Data ¡Analysis”  Beyond ¡relaPonal ¡databases SELECT key1, key2, key3, MEAN(value1), STD(value2) FROM table GROUP BY key1, key2, key2

  38. Example: ¡group-­‑by  In ¡pseudocode grouped = table.groupby(key_list) result = grouped.apply(function)

  39. Example: ¡group-­‑by  In ¡pseudocode Arrays, functions, column names, ... grouped = table.groupby(key_list) result = grouped.apply(function)

  40. Example: ¡group-­‑by  In ¡pseudocode Arrays, functions, column names, ... grouped = table.groupby(key_list) result = grouped.apply(function) Preferably, any function accepting an array or table

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend