MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Reading JSON, SQL Databases & Parquet Files0%
Study MaterialsCheatsheet
PandasProgress 0%
1.1What is Pandas & Core Architecture1.2Pandas Installation & Environment Setup1.3Creating Series & DataFrames from Scratch
2.1Reading & Writing CSV and TSV Files2.2Reading Excel Spreadsheets & Multiple Sheets2.3Reading JSON, SQL Databases & Parquet Files
HomeTutorialsPandasReading JSON, SQL Databases & Parquet Files
Indexing with loc & iloc

Reading JSON, SQL Databases & Parquet Files

Intermediate6 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

1. Modern Data Storage Formats

In enterprise data analytics, data rarely lives solely in spreadsheets. Data Analysts frequently ingest data from:

  1. 1
    REST APIs & Web Services (JSON)
  2. 2
    Relational Databases (PostgreSQL, MySQL, SQL Server, SQLite)
  3. 3
    Big Data Lakes & Cloud Warehouses (Apache Parquet)

2. Ingesting JSON Files (read_json)

JSON (JavaScript Object Notation) is hierarchical and nested.

1import pandas as pd
2 
3# Load flat JSON records
4df_users = pd.read_json('users_api.json')
5 
6# Normalize semi-structured nested JSON
7from pandas import json_normalize
8 
9raw_json = [
10 {"id": 1, "name": "Amit", "address": {"city": "Delhi", "pincode": 110001}},
11 {"id": 2, "name": "Priya", "address": {"city": "Mumbai", "pincode": 400001}}
12]
13 
14df_flat = pd.json_normalize(raw_json)
15print(df_flat)

Output:

1 id name address.city address.pincode
20 1 Amit Delhi 110001
31 2 Priya Mumbai 400001

3. Querying Relational SQL Databases (read_sql)

Pandas integrates with SQLAlchemy to query any SQL database and load the results directly into a DataFrame:

1from sqlalchemy import create_engine
2 
3# 1. Create a database connection engine (e.g., MySQL or PostgreSQL)
4engine = create_engine('sqlite:///msk_institute.db')
5 
6# 2. Execute SQL query directly into a DataFrame
7sql_query = """
8 SELECT student_id, name, course, fees_paid
9 FROM admissions
10 WHERE fees_paid > 10000
11 ORDER BY fees_paid DESC;
12"""
13 
14df_students = pd.read_sql(sql_query, con=engine)
15print(df_students.head())

4. Apache Parquet: The Fast Columnar Big Data Format

Parquet is a columnar file format that offers:

  • Up to 10x smaller file sizes via dictionary and run-length compression (snappy).
  • Up to 50x faster read speeds compared to CSV.
  • Preserved data types (no need to parse dates or specify column datatypes upon loading).
1pip install pyarrow fastparquet

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
Which function flattens semi-structured, nested JSON dictionaries into a flat 2D DataFrame?
Question 2
What library is typically used alongside pd.read_sql() to manage database connections?
Question 3
Why is Apache Parquet preferred over CSV for storing large analytics datasets?
Question 4
Which parameter in df.to_parquet() defines the underlying compression algorithm?
Question 5
What does pd.read_sql_table('employees', con=engine) do?

Next Lesson

Indexing with loc & iloc

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Reading Excel Spreadsheets & Multiple SheetsIndexing with loc & iloc

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

12-Month Data Analysis Mastery Program

Master Full-Stack Data Analytics (Excel, SQL, Python, Power BI & Tableau)

Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext