Type something to search...
Python Data Analysis Basics: Mastering Pandas Core Functions

Python Data Analysis Basics: Mastering Pandas Core Functions

Pandas is the core Python library for manipulating and analyzing tabular data, much like Excel spreadsheets or SQL tables. To get started, you need two data structures, Series and DataFrame, plus a handful of methods for loading files, selecting and filtering data, and handling missing values.

Why is Pandas the "Excel" of the Python data ecosystem?

Python became the dominant language in data science and machine learning thanks to an excellent ecosystem of libraries specialized in handling data, and Pandas sits at the center of that ecosystem.

Pandas lets you easily and powerfully manipulate and analyze tabular data in Python. It is no exaggeration to say that more than 80% of the work done by data analysts, including big data preprocessing, cleaning, filtering, and grouping, is done through Pandas.

How do you install and import Pandas?

Install the library with pip, then import it. By convention, it is imported using the alias pd.

# Install (Terminal)
# pip install pandas

# import
import pandas as pd
import numpy as np # Usually, numpy, a numerical calculation library, is also used.

What are Series and DataFrame in Pandas?

They are the two core data structures (containers) Pandas provides for storing data.

Series

Series is a data structure in the form of a one-dimensional array. It is easy to think of it as 'one column' of a table in Excel. It is similar to Python's basic list, but differs in having a label called an Index for accessing each value.

# Convert list to Pandas Series
data = ['Apple', 'Banana', 'Cherry']
s = pd.Series(data, index=['a', 'b', 'c'])
print(s)

# Output result:
# a     Apple
# b    Banana
# c    Cherry
# dtype: object

DataFrame

DataFrame is a data structure in the form of a two-dimensional table. It is composed of rows and columns, and can be viewed as multiple Series gathered together. It is the structure you will handle most in real data analysis.

# Create DataFrame using dictionary
data = {
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35],
    'City': ['New York', 'London', 'Paris']
}
df = pd.DataFrame(data)
print(df)

# Output result:
#       Name  Age      City
# 0    Alice   25  New York
# 1      Bob   30    London
# 2  Charlie   35     Paris

How do you load CSV and Excel files in Pandas?

Use pd.read_csv() and pd.read_excel(). In real work, rather than typing data into code, you load data saved as CSV or Excel files, and Pandas can read and write many formats.

# Read CSV file
df_csv = pd.read_csv('sales_data.csv')

# Read Excel file
df_excel = pd.read_excel('report.xlsx')

# Preview the first 5 rows (essential to understand what the data looks like!)
print(df_csv.head())

# Summary of overall information of the data frame (missing values, data type, etc.)
df_csv.info()

How do you select and filter data in Pandas?

Select columns by name, filter rows with conditions (Boolean Indexing), and pick specific positions with loc and iloc. Extracting only the information you want from a massive DataFrame is the core skill of Pandas.

Select a column

# Select only the 'Name' column (results are returned in Series format)
names = df['Name']

# When selecting multiple columns at the same time, group them into a list.
subset = df[['Name', 'City']]

Filtering rows that meet conditions (Boolean Indexing)

This works like the filter function in Excel, extracting only rows that satisfy specific conditions.

# Filter only people over 30 years old
over_30 = df[df['Age'] >= 30]

# When combining multiple conditions (AND: &, OR: |)
# Caution: You must use parentheses () for each conditional expression.
condition_df = df[(df['Age'] >= 30) & (df['City'] == 'London')]

Select data from specific location (loc, iloc)

  • loc[]: Select based on the 'label (name)' of the index.
  • iloc[]: Select based on the 'position (integer number)' of the index.
# Get all data in row with index 0 (based on name)
row_0 = df.loc[0]

# Get data from row 0, column 1 (based on numbers)
val = df.iloc[0, 1]

How do you handle missing data in Pandas?

Check for missing values with isnull(), then either drop them with dropna() or fill them with fillna(). Real data is often empty (NaN, Not a Number) or full of invalid values, so handling missing values in the cleaning (preprocessing) stage is essential before analysis.

# Check if there are any missing values
print(df.isnull().sum())

# Delete rows containing at least one missing value
df_dropped = df.dropna()

# Fill missing values ​​with another value (e.g. 0 or the mean value of a column)
mean_age = df['Age'].mean()
df_filled = df.fillna(mean_age)

What should you learn next?

Beyond these basics, Pandas has extensive built-in functions such as data merging (Merge, Concat), grouping and aggregation (GroupBy), and time series data processing.

Rather than trying to memorize every function from scratch, download a CSV dataset that interests you from Kaggle or a public data portal, load it, and experiment with it. Working with real data and wrestling with error messages is one of the best ways to learn.

Related Post

AI-Native Development: The End of Traditional Coding as We Knew It

AI-Native Development: The End of Traditional Coding as We Knew It

AI-Native Development Platforms go beyond autocomplete: they treat the AI as a core member of the engineering team that understands your whole repository and can propose architecture, generate se

The Prototype Economy: How AI Makes a Fully Working App Possible in 48 Hours

The Prototype Economy: How AI Makes a Fully Working App Possible in 48 Hours

The Prototype Economy is the 2026 reality where AI coding assistants, agentic workflows, and generative design tools shrink the gap between an idea and a clickable prototype from months to minute

Down the Rabbit Hole: Building Your First Custom Mechanical Keyboard

Down the Rabbit Hole: Building Your First Custom Mechanical Keyboard

Building a custom mechanical keyboard from scratch comes down to four stages: choosing a barebones kit, picking and lubing switches, tuning the stabilizers, and fitting keycaps. It is slow, fiddly wo

Self-Hosting a Developer's NAS: Replacing Paid Cloud Storage

Self-Hosting a Developer's NAS: Replacing Paid Cloud Storage

A custom NAS can do far more than store files: for a developer, it can replace paid cloud storage, private Git hosting, and on-demand CI servers with a single box at home. The trade-off is that you b

Can a Dual-Screen Laptop Replace a Multi-Monitor Desktop? A 2026 Developer Review

Can a Dual-Screen Laptop Replace a Multi-Monitor Desktop? A 2026 Developer Review

A dual-screen laptop can stand in for a multi-monitor desktop, but only for certain people. It shines for hybrid workers and digital nomads who need a full workspace on the move; for someone who sits

Enterprise Agentic AI: From Prompting to Delegating in 2026

Enterprise Agentic AI: From Prompting to Delegating in 2026

Enterprise agentic AI means handing whole workflows to coordinated teams of AI agents instead of prompting a single assistant line by line. In 2026 the shift is less about better autocomplete and mor

Feeling the Digital World: Haptic VR Gloves for Remote Work

Feeling the Digital World: Haptic VR Gloves for Remote Work

Consumer-grade haptic VR gloves add the missing sense of touch to spatial computing: virtual buttons push back, digital objects resist your grip, and textures can be felt through micro-vibrations. As

Migrating from React to HTMX: Is It Worth It? (A Practical Review)

Migrating from React to HTMX: Is It Worth It? (A Practical Review)

Moving a React back-office to HTMX is worth it for data-heavy admin screens: frontend code shrinks dramatically, backend developers can ship UI directly, and the HTMX library itself is only about

The Golden Age of Solo Dev: Building Games in Your Bedroom with AI

The Golden Age of Solo Dev: Building Games in Your Bedroom with AI

In 2026, a single person can realistically build a polished game from their bedroom. Visual scripting in modern game engines removes much of the coding barrier, generative AI covers art, music and de

Can the 2026 iPad Pro Actually Replace a MacBook for Developers? A Practical Breakdown

Can the 2026 iPad Pro Actually Replace a MacBook for Developers? A Practical Breakdown

No, the 2026 M4 iPad Pro cannot fully replace a MacBook for a professional developer. It works remarkably well as a thin client for remote development over SSH, but the lack of local Docker, a na

Coding with OpenAI's o1 Model: Strengths, Limits and Costs

Coding with OpenAI's o1 Model: Strengths, Limits and Costs

OpenAI's o1 model, launched in 2024, is a reasoning model: instead of answering as fast as possible like GPT-4o, it works through a "Chain of Thought" before replying. For coding, that makes it s

The Complete Guide to Docker: Introduction to and Use of Container Technology for Beginners

The Complete Guide to Docker: Introduction to and Use of Container Technology for Beginners

Docker is a platform that packages an application and everything it needs into a standardized, portable unit called a container, so it runs the same way on any machine. Containers share the host oper

Mastering Kubernetes: Container Orchestration Beyond Docker

Mastering Kubernetes: Container Orchestration Beyond Docker

Kubernetes (k8s) is a container orchestration tool that automates deploying, scaling, and managing dozens or hundreds of containers across many servers. Where Docker packages a single application, Ku

The Complete Guide to Git Branching Strategy: From Git Flow to GitHub Flow

The Complete Guide to Git Branching Strategy: From Git Flow to GitHub Flow

Why does a team need a Git branching strategy? A shared branching strategy keeps a multi-developer repository from descending into chaos. The three most widely used are Git Flow (structured, for

React vs Vue.js: Guide to Choosing a Front-End Framework in 2024

React vs Vue.js: Guide to Choosing a Front-End Framework in 2024

React or Vue.js: which should you choose? Choose React for large, long-lived projects, mobile apps via React Native, and the biggest job market and ecosystem; choose Vue.js for fast prototypes, m

Website Performance Optimization Strategies: How Loading Speed ​​​​Affects Your Business

Website Performance Optimization Strategies: How Loading Speed ​​​​Affects Your Business

Loading speed directly affects revenue: even a fraction of a second of delay can lower sales and push visitors away. The most effective front-end fixes are optimizing images, shrinking text resources

Complete CI/CD pipeline automation starting with GitHub Actions

Complete CI/CD pipeline automation starting with GitHub Actions

CI/CD replaces error-prone manual deployment with automated builds, tests, and releases, and GitHub Actions is one of the easiest ways to set it up because it runs directly inside your GitHub reposit

TypeScript 101: Putting ‘seatbelts’ on JavaScript

TypeScript 101: Putting ‘seatbelts’ on JavaScript

TypeScript is JavaScript with static types: it catches type errors in your editor or at build time, before the code ever runs. For anything beyond a short hackathon or a very light script, adopting i

Practical guide to developer-prompted engineering in the era of generative AI

Practical guide to developer-prompted engineering in the era of generative AI

Prompt engineering for developers means structuring instructions so that generative AI (ChatGPT, Claude, etc.) produces code you can actually use: give the AI a role, explain the project context, sta

Front-end ecosystem trends in 2024: What should we learn and prepare for?

Front-end ecosystem trends in 2024: What should we learn and prepare for?

The front-end development trend in 2024 can be summarized as a 'return to server-side rendering' and 'extreme performance optimization'. The four trends to learn and prepare for are React Ser

Data-based decision making and big data analysis trends in 2024

Data-based decision making and big data analysis trends in 2024

Data-Driven Decision Making (DDDM) means basing business choices on objective data analysis instead of intuition, and it has become a core survival strategy. In 2024 it is supported by four big data