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
Creating Series & DataFrames from Scratch0%
Study MaterialsCheatsheet
PandasProgress 0%
1.1What is Pandas & Core Architecture1.2Pandas Installation & Environment Setup1.3Creating Series & DataFrames from Scratch
HomeTutorialsPandasCreating Series & DataFrames from Scratch
Reading & Writing CSV and TSV Files

Creating Series & DataFrames from Scratch

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

1. Creating a Pandas Series

A pd.Series can be created from Python lists, dictionaries, tuples, or NumPy arrays.

A. From a Python List

1import pandas as pd
2 
3# Creating a series with custom string index
4temperatures = pd.Series([32.5, 34.0, 31.8, 35.2], index=['Delhi', 'Agra', 'Noida', 'Mathura'], name='Temp_Celsius')
5print(temperatures)

Output:

1Delhi 32.5
2Agra 34.0
3Noida 31.8
4Mathura 35.2
5Name: Temp_Celsius, dtype: float64

B. From a Python Dictionary

When creating a Series from a dictionary, the dictionary keys automatically become the Series Index, and the dictionary values become the data:

1student_scores = {'Amit': 88, 'Sunita': 94, 'Kavita': 91, 'Rahul': 76}
2scores_series = pd.Series(student_scores, name='Math_Score')
3print(scores_series)

2. Creating DataFrames from Scratch

Method 1: Dictionary of Lists / Arrays (Most Common)

Here, each key becomes a Column Name, and the corresponding list becomes the column values (all lists must be of equal length):

1data = {
2 'Student_ID': [101, 102, 103, 104],
3 'Name': ['Deepak', 'Ananya', 'Vikas', 'Pooja'],
4 'City': ['Shikohabad', 'Firozabad', 'Agra', 'Lucknow'],
5 'Marks': [85.5, 92.0, 78.5, 95.0]
6}
7 
8df = pd.DataFrame(data)
9print(df)

Output:

1 Student_ID Name City Marks
20 101 Deepak Shikohabad 85.5
31 102 Ananya Firozabad 92.0
42 103 Vikas Agra 78.5
53 104 Pooja Lucknow 95.0

Method 2: List of Dictionaries (Row-Oriented Format)

Often data comes from REST APIs or MongoDB as a list of JSON records:

1records = [
2 {'Product': 'Laptop', 'Price': 55000, 'Stock': 12},
3 {'Product': 'Mouse', 'Price': 650, 'Stock': 80},
4 {'Product': 'Keyboard', 'Price': 1500, 'Stock': 45}
5]
6 
7df_products = pd.DataFrame(records)
8print(df_products)

Method 3: From a 2D NumPy Array with Custom Columns

1import numpy as np
2 
3matrix = np.random.randint(10, 100, size=(3, 3))
4df_matrix = pd.DataFrame(matrix, columns=['A', 'B', 'C'], index=['Row_1', 'Row_2', 'Row_3'])
5print(df_matrix)

3. Essential Inspection Attributes

Once a DataFrame is instantiated, inspect its dimensions and metadata immediately:

1print(df.shape) # (rows, columns) -> (4, 4)
2print(df.columns) # Index(['Student_ID', 'Name', 'City', 'Marks'], dtype='object')
3print(df.index) # RangeIndex(start=0, stop=4, step=1)
4print(df.dtypes) # Datatypes for each column

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
When creating a Pandas Series from a standard Python dictionary, what do the dictionary keys become?
Question 2
If you construct a DataFrame from a dictionary of lists, what requirement must be satisfied?
Question 3
Which attribute returns a tuple representing the dimensionality (rows, columns) of a DataFrame?
Question 4
What is the output of df.dtypes?
Question 5
What does the df.head(3) method do?

Next Lesson

Reading & Writing CSV and TSV Files

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

Related Lessons

Previous LessonNext Lesson
Pandas Installation & Environment SetupReading & Writing CSV and TSV Files

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