Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Neat Analytics with Pandas Indexes, Alexander Hendorf

268 views

Published on

PyParis 2017
http://pyparis.org

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Neat Analytics with Pandas Indexes, Alexander Hendorf

  1. 1. Neat Analytics with Pandas A Closer Look at Pandas Indexing Alexander C. S. Hendorf @hendorf
  2. 2. Alexander C. S. Hendorf Königsweg GmbH Strategic data consulting for startups and the industry. EuroPython & PyConDE 
 Organisator + Programm Chair mongoDB master, PSF managing member Speaker mongoDB days, EuroPython, PyData… @hendorf
  3. 3. Today Closer Look at Indexes - Catch up on Pandas indexing - Accessing data using the index - Index Types - MultiIndex - Closer look at DateTimeIndex and Resampling
  4. 4. Structure: Index -the label of a series is usually called index -automatically created if not given -can be reset or replaced -immutable ndarray implementing an ordered, sliceable set -can only contain hashable objects -one or more dimensions -may contain a value more than once (NOT UNIQUE!)
  5. 5. Index Types -Index -MultiIndex -DateTimeIndex -TimeDelta -IntervalIndex -CategoricalIndex
  6. 6. Structure DataFrame 2D 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 … Panel 3DXXXXXXXXX pd.Series 1D 1 2 3 4 5 6 7 1 2 3 4 5 6 7 Index Data: Numpy array
  7. 7. Axes 1 2 3 0 1 0 1 2 3 4 5 6
  8. 8. no match: NaN only if index matches
  9. 9. MultiIndex
  10. 10. max value of each series (not row) get level 0 data get level 1 data get level 2 data • • • •
  11. 11. DateTimeIndex -index of datetime64 data
  12. 12. 2014-09-26T03:50:00,14.0 2014-08-10T05:00:00,14 2014-08-21T22:50:00,12.0 2014-08-17T13:20:00,16.0 2014-08-06T01:20:00,14.0 2014-09-27T06:50:00,11.0 2014-08-25T21:50:00,13.0 2014-08-14T05:20:00,13.0 2014-09-14T05:20:00,16.0 2014-08-03T02:50:00,21.0 2014-09-29T03:00:00,13 2014-09-06T08:20:00,16.0 2014-08-19T07:20:00,13.0 2014-09-27T22:50:00,10.0 2014-08-28T08:20:00,12.0 2014-08-17T01:00:00,14 2014-09-27T14:00:00,17 2014-09-10T18:00:00,18 2014-09-22T23:00:00,8 2014-09-20T03:00:00,9 2014-08-29T09:50:00,16.0 2014-08-16T01:50:00,13.0
  13. 13. DateTime format="%d.%m.%Y %H:%M:%S
  14. 14. before DateTimeIndex: unordered
  15. 15. Resampling
  16. 16. Resampling -H hourly frequency -T minutely frequency -S secondly frequency -L milliseonds -U microseconds -N nanoseconds -D calendar day frequency -W weekly frequency -M month end frequency -Q quarter end frequency -A year end frequency - B business day frequency - C custom business day frequency (experimenta - BM business month end frequency - CBM custom business month end frequency - MS month start frequency - BMS business month start frequency - CBMS custom business month start frequency - BQ business quarter endfrequency - QS quarter start frequency - BQS business quarter start frequency - BA business year end frequency - AS year start frequency - BAS business year start frequency - BH business hour frequency
  17. 17. Extra discounts for students & post docs #16 180+sessions 18free trainings panels open spaces 5dtalks & trainings 2dsprints beginners’ day Tickets start @ 375€ Rimini . Venice ! Bologna ! ✈ . Florence ! . # $ Rome ! . Armin Rohnacher • Katharine Jarmul • Tracy Osborn Jan Willem Tulp • Aisha Bello & Daniele Procida interactive sessions
  18. 18. 25. - 27. October ZKM, Karlsruhe CfP is open!
  19. 19. Alexander C. S. Hendorf ah@koenigsweg.com @hendorf

×