Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Wrangling with Python

You're reading from   Data Wrangling with Python Creating actionable data from raw sources

Arrow left icon
Product type Paperback
Published in Feb 2019
Publisher Packt
ISBN-13 9781789800111
Length 452 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Shubhadeep Roychowdhury Shubhadeep Roychowdhury
Author Profile Icon Shubhadeep Roychowdhury
Shubhadeep Roychowdhury
Dr. Tirthajyoti Sarkar Dr. Tirthajyoti Sarkar
Author Profile Icon Dr. Tirthajyoti Sarkar
Dr. Tirthajyoti Sarkar
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Data Wrangling with Python
Preface
1. Introduction to Data Wrangling with Python FREE CHAPTER 2. Advanced Data Structures and File Handling 3. Introduction to NumPy, Pandas, and Matplotlib 4. A Deep Dive into Data Wrangling with Python 5. Getting Comfortable with Different Kinds of Data Sources 6. Learning the Hidden Secrets of Data Wrangling 7. Advanced Web Scraping and Data Gathering 8. RDBMS and SQL 9. Application of Data Wrangling in Real Life Appendix

Useful Methods of Pandas


In this topic, we will discuss some small utility functions that are offered by pandas so that we can work efficiently with DataFrames. They don't fall under any particular group of function, so they are mentioned here under the Miscellaneous category.

Exercise 57: Randomized Sampling

Sampling a random fraction of a big DataFrame is often very useful so that we can practice other methods on them and test our ideas. If you have a database table of 1 million records, then it is not computationally effective to run your test scripts on the full table.

However, you may also not want to extract only the first 100 elements as the data may have been sorted by a particular key and you may get an uninteresting table back, which may not represent the full statistical diversity of the parent database.

In these situations, the sample method comes in super handy so that we can randomly choose a controlled fraction of the DataFrame:

  1. Specify the number of samples that you require from...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime