Download Complete Python for Data Analysis Data Wrangling with Pandas NumPy and IPython 1st Edition Wes Mckinney PDF for All Chapters
Download Complete Python for Data Analysis Data Wrangling with Pandas NumPy and IPython 1st Edition Wes Mckinney PDF for All Chapters
com
https://ebookmeta.com/product/python-for-data-analysis-data-
wrangling-with-pandas-numpy-and-ipython-1st-edition-wes-
mckinney/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/python-data-analysis-numpy-matplotlib-
and-pandas-bernd-klein/
ebookmeta.com
https://ebookmeta.com/product/python-for-data-analysis-3rd-edition-
second-early-release-wes-mckinney/
ebookmeta.com
https://ebookmeta.com/product/illiberal-europe-eastern-europe-from-
the-fall-of-the-berlin-wall-to-the-war-in-ukraine-2nd-edition-leon-
marc/
ebookmeta.com
Mapping the Field of Adult and Continuing Education An
International Compendium 1st Edition Alan B. Knox
https://ebookmeta.com/product/mapping-the-field-of-adult-and-
continuing-education-an-international-compendium-1st-edition-alan-b-
knox/
ebookmeta.com
https://ebookmeta.com/product/what-really-happens-in-vegas-true-
stories-of-the-people-who-make-vegas-vegas-1st-edition-patterson/
ebookmeta.com
https://ebookmeta.com/product/marketing-research-delivering-customer-
insight-4th-edition-alan-wilson/
ebookmeta.com
https://ebookmeta.com/product/competition-cauldrons-conspiracy-
moonflower-mystery-5-1st-edition-beverly-rearick/
ebookmeta.com
Python for Data Analysis
Download from Wow! eBook <www.wowebook.com>
Wes McKinney
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or [email protected].
Editors: Julie Steele and Meghan Blanchette Indexer: BIM Publishing Services
Production Editor: Melanie Yarbrough Cover Designer: Karen Montgomery
Copyeditor: Teresa Exley Interior Designer: David Futato
Proofreader: BIM Publishing Services Illustrator: Rebecca Demarest
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Python for Data Analysis, the cover image of a golden-tailed tree shrew, and related
trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-31979-3
[LSI]
1349356084
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1. Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
What Is This Book About? 1
Why Python for Data Analysis? 2
Python as Glue 2
Solving the “Two-Language” Problem 2
Why Not Python? 3
Essential Python Libraries 3
NumPy 4
pandas 4
matplotlib 5
IPython 5
SciPy 6
Installation and Setup 6
Windows 7
Apple OS X 9
GNU/Linux 10
Python 2 and Python 3 11
Integrated Development Environments (IDEs) 11
Community and Conferences 12
Navigating This Book 12
Code Examples 13
Data for Examples 13
Import Conventions 13
Jargon 13
Acknowledgements 14
2. Introductory Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.usa.gov data from bit.ly 17
Counting Time Zones in Pure Python 19
iii
Counting Time Zones with pandas 21
MovieLens 1M Data Set 26
Measuring rating disagreement 30
US Baby Names 1880-2010 32
Analyzing Naming Trends 36
Conclusions and The Path Ahead 43
iv | Table of Contents
Operations between Arrays and Scalars 85
Basic Indexing and Slicing 86
Boolean Indexing 89
Fancy Indexing 92
Transposing Arrays and Swapping Axes 93
Universal Functions: Fast Element-wise Array Functions 95
Data Processing Using Arrays 97
Expressing Conditional Logic as Array Operations 98
Mathematical and Statistical Methods 100
Methods for Boolean Arrays 101
Sorting 101
Unique and Other Set Logic 102
File Input and Output with Arrays 103
Storing Arrays on Disk in Binary Format 103
Saving and Loading Text Files 104
Linear Algebra 105
Random Number Generation 106
Example: Random Walks 108
Simulating Many Random Walks at Once 109
Table of Contents | v
Other pandas Topics 151
Integer Indexing 151
Panel Data 152
vi | Table of Contents
8. Plotting and Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
A Brief matplotlib API Primer 219
Figures and Subplots 220
Colors, Markers, and Line Styles 224
Ticks, Labels, and Legends 225
Annotations and Drawing on a Subplot 228
Saving Plots to File 231
matplotlib Configuration 231
Plotting Functions in pandas 232
Line Plots 232
Bar Plots 235
Histograms and Density Plots 238
Scatter Plots 239
Plotting Maps: Visualizing Haiti Earthquake Crisis Data 241
Python Visualization Tool Ecosystem 247
Chaco 248
mayavi 248
Other Packages 248
The Future of Visualization Tools? 249
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Table of Contents | ix
Preface
The scientific Python ecosystem of open source libraries has grown substantially over
the last 10 years. By late 2011, I had long felt that the lack of centralized learning
resources for data analysis and statistical applications was a stumbling block for new
Python programmers engaged in such work. Key projects for data analysis (especially
NumPy, IPython, matplotlib, and pandas) had also matured enough that a book written
about them would likely not go out-of-date very quickly. Thus, I mustered the nerve
to embark on this writing project. This is the book that I wish existed when I started
using Python for data analysis in 2007. I hope you find it useful and are able to apply
these tools productively in your work.
xi
This icon indicates a warning or caution.
xii | Preface
How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://oreil.ly/python_for_data_analysis.
To comment or ask technical questions about this book, send email to
[email protected].
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Preface | xiii
Other documents randomly have
different content
Ketling tunsi, että hänen oli aika mennä, mutta hän ei liikahtanut
paikaltaan. Hänen kalpeat huulensa liikkuivat, mutta eivät saaneet
lausutuksi sanaakaan.
— Älä itke! Kmicic tuli mieleeni vain sen vuoksi, että hän edes
kykenisi vapauttamaan meidät tästä Babylonian vankeudesta. Kyllä
hän näyttäisi noille kaikille Brauneille, Ketlingeille, Patersoneille ja
itse Boguslawillekin! Ne ovat kaikki samanlaisia pettureita! Älä itke,
ei itku mitään auta! Tässä täytyy keksiä neuvot. Koska Ketling ei
tahdo auttaa hitto hänet vieköön! — niin meidän on tultava omin
neuvoin toimeen. Sinulla on muka miehuullinen mieli, mutta tärkeällä
hetkellä et osaa muuta kuin nyyhkyttää. Kyllä me selviydymme!
Braun otti hänet sangen ystävällisesti vastaan, koska niin oli pakko
tehdä, sillä niin määräsi Sakowicz kirjeessä, jonka Boguslaw itse oli
allekirjoittanut ja jossa ruhtinatar Gryzelda Wisniowieckin hovineidille
käskettiin osoittamaan kaikkea kunnioitusta. Neiti Anna oli reippaalla
mielellä ja alkoi heti tulostaan asti heitellä Brauniin semmoisia
silmäyksiä, että juro saksalaisparka kulki kuin tulisilla hiilillä. Muitakin
upseereita neiti Anna alkoi komennella ja oli Taurogissa kuin
kotonaan. Jo ensimmäisenä iltana hän tutustui Oleńkaan, joka tosin
katseli häntä epäluuloisesti, mutta otti hänet vastaan kohteliaasti
toivoen saavansa kuulla uutisia.
Sen nähdessään Anusia, jolla oli hyvä sydän, hypähti heti Oleńkan
luo, kietoi kätensä hänen kaulaansa ja sanoi:
— Eikö se onnistunut?
— Kuka se on?
— Suokoon Jumala!
— Minä sanon teille, miksi luulen niin… Joka kerta nimittäin, kun
tuo
Babinicz mainitsi ruhtinas Boguslawin, hän kalpeni ja puri
hammasta.
— Entä Fitz-Gregory?
— Von Irben?
— Samoin!
— Tepä vasta olette!… Nähtävästi siis vain Kettingistä ei teidän
ole onnistunut selviytyä!
Ketling sen sijaan alkoi taas käydä Oleńkan puheilla, sillä kun he
kerran olivat kohdanneet toisensa, oli tyttö ojentanut hänelle
kätensä. Nuori upseeri piti hiljaisuutta pahana merkkinä. Hänen
mielestään ruhtinas jo ruotsalaisten ja vaaliruhtinaan takia olisi
pitänyt ääntä pienestäkin voitosta.
Herra Andrzej!