Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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

Activity 15: Data Wrangling Task – Connecting the New Data to the Database


The steps to connect the data to the database is as follows:

  1. Import the sqlite3 module of Python and use the connect function to connect to the database. The main database engine is embedded. But for a different database like Postgresql or MySQL, we will need to connect to them using those credentials. We designate Year as the PRIMARY KEY of this table.

  2. Then, run a loop with the dataset rows one by one to insert them into the table.

  3. If we look at the current folder, we should see a file called Education_GDP.db, and if we examine that using a database viewer program, we can see the data transferred there.

Note

The solution for this activity can be found on page 347.

In this notebook, we examined a complete data wrangling flow, including reading data from the web and local drive, filtering, cleaning, quick visualization, imputation, indexing, merging, and writing back to a database table. We also wrote custom functions to...

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 $19.99/month. Cancel anytime
Banner background image