Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Pandas Cookbook
  • Table Of Contents Toc
Pandas Cookbook

Pandas Cookbook - Third Edition

By : William Ayd, Matthew Harrison
4.9 (10)
close
close
Pandas Cookbook

Pandas Cookbook

4.9 (10)
By: William Ayd, Matthew Harrison

Overview of this book

Unlock the full power of pandas 2.x with this hands-on cookbook, designed for Python developers, data analysts, and data scientists who need fast, efficient solutions for real-world data challenges. This book provides practical, ready-to-use recipes to streamline your workflow. With step-by-step guidance, you'll master data wrangling, visualization, performance optimization, and scalable data analysis using pandas’ most powerful features. From importing and merging large datasets to advanced time series analysis and SQL-like operations, this cookbook equips you with the tools to analyze, manipulate, and visualize data like a pro. Learn how to boost efficiency, optimize memory usage, and seamlessly integrate pandas with NumPy, PyArrow, and databases. This book will help you transform raw data into actionable insights with ease. *Email sign-up and proof of purchase required
Table of Contents (14 chapters)
close
close
12
Other Books You May Enjoy
13
Index

Selection by data type

So far in this cookbook, we have seen data types, but we have not talked too much in depth about what they are. We still aren’t quite there; a deep dive into the type system of pandas is reserved for Chapter 3, Data Types. However, for now, you should be aware that the column type provides metadata that pd.DataFrame.select_dtypes can use for selection.

How to do it

Let’s start with a pd.DataFrame that uses integral, floating point, and string columns:

df = pd.DataFrame([
    [0, 1.0, "2"],
    [4, 8.0, "16"],
], columns=["int_col", "float_col", "string_col"])
df
    int_col   float_col   string_col
0   0         1.0         2
1   4         8.0         16

Use pd.DataFrame.select_dtypes to select only integral columns:

df.select_dtypes("int")
    int_col
0   0
1   4

Multiple types can be selected if you pass a list argument:

df.select_dtypes(include...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Pandas Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon