Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorWes McKinney

Get complete instructions for manipulating, processing, cleaning, and crunching datasets in Python. Updated for Python 3.6, the second edition of this hands-on guide is packed with practical case studies that show you how to solve a broad set of data analysis problems effectively. You’ll learn the latest versions of pandas, NumPy, IPython, and Jupyter in the process. Written by Wes McKinney, the creator of the Python pandas project, this book is a practical, modern introduction to data science tools in Python. It’s ideal for analysts new to Python and for Python programmers new to data science and scientific computing. Data files and related material are available on GitHub. Use the IPython shell and Jupyter notebook for exploratory computing Learn basic and advanced features in NumPy (Numerical Python) Get started with data analysis tools in the pandas library Use flexible tools to load, clean, transform, merge, and reshape data Create informative visualizations with matplotlib Apply the pandas groupby facility to slice, dice, and summarize datasets Analyze and manipulate regular and irregular time series data Learn how to solve real-world data analysis problems with thorough, detailed examples

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on, practical introduction to data analysis in Python, this book teaches you how to load, clean, transform, and visualize data using pandas, NumPy, and IPython/Jupyter—ideal for analysts new to Python or programmers new to scientific computing. 【Book Arc】 - **Opening (~0%–9%)**: Sets up the environment and core concepts. Covers installing Python via Anaconda, managing packages with conda/pip, and introduces the IPython shell and Jupyter notebook as the primary exploratory computing tools. - **Early (~9%–25%)**: Builds Python language fundamentals. Reviews scalar types, mutable vs. immutable objects, control flow (if/for loops with break/continue), data structures like lists, dicts, and sets, plus generators and the iterator protocol—essential groundwork for data work. - **Early (~25%–34%)**: Dives into NumPy basics. Explains array creation, indexing (including boolean and fancy indexing), vectorized operations, and the np.where function for conditional logic—the foundation for fast numerical computation. - **Middle (~34%–44%)**: Advances NumPy skills. Covers mathematical and statistical methods (sum, mean, std) with axis arguments, array-oriented programming, and a practical example of simulating random walks using cumulative sums. - **Middle (~44%–47%)**: Introduces pandas data structures. Focuses on Series and DataFrame, including the drop method for deleting rows/columns, handling arithmetic with differently indexed objects (fill_value), and the complications of duplicate axis labels. 【Key Takeaways】 - **Environment setup is the first hurdle** (Opening): Use Anaconda for a reproducible Python data stack; prefer conda over pip for updating packages to avoid environment conflicts. This saves hours of dependency headaches. - **IPython/Jupyter are the exploratory workhorses** (Opening): Nearly all commands work in both the shell and notebook; magic functions and matplotlib integration make iterative analysis fluid. Master Shift-Enter in notebooks for quick experimentation. - **Immutability reduces bugs** (Early): Python objects are mostly mutable, but side effects in functions should be avoided; favor immutable types like tuples where possible for safer code. - **Generators enable lazy, memory-efficient iteration** (Early): Using yield instead of return creates sequences that produce values on demand—critical for handling large datasets without loading everything at once. - **NumPy vectorization replaces slow loops** (Early–Middle): Boolean and fancy indexing let you select and modify array subsets in one line; np.where offers clean conditional logic. This is the key to fast numerical work. - **Axis-aware aggregations are powerful** (Middle): Methods like sum and mean accept an axis argument to compute statistics over rows or columns, reducing multidimensional data efficiently. - **pandas alignment handles mismatched data gracefully** (Middle): Arithmetic between differently indexed objects produces NaN for non-overlapping labels; use add with fill_value to control missing data behavior. - **Duplicate labels complicate indexing** (Middle): When axis labels repeat, indexing returns a Series instead of a scalar, making output types unpredictable—check is_unique and design data accordingly. 【Reading Tips】 - **Skim the Python basics chapter** (~9%–25%) if you're already comfortable with Python; focus instead on the NumPy and pandas sections where the real value lies. - **Deep-read the NumPy chapters** (~25%–44%): Work through the array indexing and np.where examples line-by-line in Jupyter—these patterns recur throughout the book. - **Pay special attention to the pandas alignment section** (~44%–47%): Understanding how NaN propagates in arithmetic is crucial for real-world data cleaning; test the fill_value examples yourself. - **Practice with the random walk example** (~38%–44%): It ties together NumPy's random module, vectorization, and cumulative sums—a mini-project that solidifies core skills. - **Keep the book's GitHub repo handy**: The companion notebooks let you follow along without typing every example, but type the key ones manually to build muscle memory. 【Coverage Limits】 The excerpts cover roughly the first half of the book (through pandas fundamentals). Later chapters on data cleaning, merging, visualization with matplotlib, groupby, and time series are not covered in this guide.
Page 10
(Leading and Lagging) Data 332 11.4 Time Zone Handling 335 Time Zone Localization and Conversion 335 Operations with Time Zone−Aware Timestamp Objects 338 Op...
View in text
Excerpt 2
, boolean (True or False) values, and dates and time. These “single value” types are sometimes called scalar types and we refer to them in this book as scala...
View in text
Excerpt 3
0xb1 in position 0: invalid s tart byte In [244]: f.close() If you find yourself regularly doing data analysis on non-ASCII text data, mastering Python’s Uni...
View in text
Excerpt 4
4.0 5.0 6.0 7.0 2 8.0 9.0 10.0 11.0 In [169]: df2 Out[169]: a b c d e 0 0.0 1.0 2.0 3.0 4.0 1 5.0 NaN 7.0 8.0 9.0 2 10.0 11.0 12.0 13.0 14.0 3 15.0 16.0 17.0...
View in text
Excerpt 5
ed by pandas.cut. You can treat it like an array of strings indicating the bin name; internally it contains a categories array specifying the dis‐ tinct cate...
View in text
Excerpt 6
the percent of the figure width and figure height, respec‐ tively, to use as spacing between subplots. Here is a small example where I shrink the spacing all...
View in text
Excerpt 7
these basic usage mechanics, getting the most out of apply may require some creativity. What occurs inside the function passed is up to you; it only needs to...
View in text
Excerpt 8
n', or Second(15)) axis Axis to resample on; default axis=0 fill_method How to interpolate when upsampling, as in 'ffill' or 'bfill';
View in text
Tags
AI categories
DataProgrammingPython
ISBN: 1491957662
Publisher: O’Reilly Media
Publish Year: 2017
Language: English
Pages: 544
File Format: PDF
File Size: 12.5 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…