Importing data from various sources (CSV, Excel, SQL)

LipikaSharmaShrivast 126 views 15 slides Aug 28, 2024
Slide 1
Slide 1 of 15
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

Module 4: Data Collection and Cleaning with Python


Slide Content

Data Collection and Cleaning with Python

Replay Module 3 Introduction to Python for Data Science Python programming Concepts (Functions, classes and Oops concept) Introduction to Jupyter Notebooks and Anaconda Basic data manipulation with pandas

Session 10: Importing data from various sources Agenda Introduction to Data Importing Overview of CSV Format and Importing CSV Data (Python Example) Overview of Excel Format and Importing Excel Data (Python Example) Overview of SQL Databases and Importing SQL Data (Python Example) Combining Data from Multiple Sources and Storing Imported Data Exporting the files in the destination.

Introduction to Data Importing The process of loading data from different external sources into a software environment.

Overview of CSV Format Comma-Separated Values, a simple file format used to store tabular data. Rows of data with fields separated by commas.

Importing CSV Data (Python Example) import pandas as pd df = pd.read_csv ('data.csv') print( df.head ())

Overview of Excel Format Microsoft Excel  enables users to format, organize and calculate data in a spreadsheet . By organizing data using software like Excel, data analysts and other users can make information easier to view as data is added or changed. Excel contains a large number of boxes called cells that are ordered in rows and columns. Microsoft Excel file formats (XLS, XLSX) used for spreadsheets. Features: Supports multiple sheets, rich formatting, formulas.

Importing Excel Data (Python Example) Single Sheet df = pd.read_excel ('data.xlsx', sheet_name ='Sheet1') print( df.head ()) Handling Multiple Sheets: all_sheets_df = pd.read_excel ('data.xlsx', sheet_name =None)

Overview of SQL Databases Definition: Structured Query Language databases like MySQL, PostgreSQL, SQLite. Features: Supports complex queries, relationships, transactions. Example: Employees database with tables for departments, salaries, etc.

Importing SQL Data (Python Example) from sqlalchemy import create_engine engine = create_engine (' mysql :// username:password@localhost / dbname ') df = pd.read_sql ('SELECT * FROM employees', engine) print( df.head ())

Save the DataFrame to CSV

Q N A

Q What is data importing?

Q What does CSV stand for and what is its format?

Q How can you import SQL data in Python?