Introduction to Pandas for Pharmacy Students (Pharma Data Analysis & Why Pandas Over CSV/NumPy)
Pandas is one of the most powerful Python libraries used for data analysis. In pharmaceutical sciences, it plays a crucial role in handling patient datasets, pharmacokinetic (PK) studies, and ADR reports.
๐ท What is Pandas?
Pandas is a Python library used for data manipulation and analysis. It provides easy-to-use data structures and functions for working with structured data.
๐ท Importing Pandas
import pandas as pd
๐ท Why Pandas in Pharmacy?
- Handles large datasets efficiently
- Supports CSV and Excel files
- Provides statistical analysis tools
- Useful for PK and ADR data analysis
๐ Pharma Dataset Example
| Patient | Drug | Dose | Reaction |
|---|---|---|---|
| P001 | Aspirin | 500 | Mild |
| P002 | Ibuprofen | 650 | Severe |
Pandas helps analyze such datasets easily.
๐ท Why Pandas Over CSV Module?
| Feature | CSV Module | Pandas |
|---|---|---|
| Ease of use | Low | High |
| Data analysis | Limited | Advanced |
| Filtering | Manual | Built-in |
๐ท Why Pandas Over NumPy?
| Feature | NumPy | Pandas |
|---|---|---|
| Data Type | Arrays | Tables |
| Labelled Data | No | Yes |
| Real-world Data | Limited | Excellent |
๐ท Simple Pandas Example
import pandas as pd
data = {
"Patient": ["P001", "P002"],
"Dose": [500, 650]
}
df = pd.DataFrame(data)
print(df)
๐ง Memory Tricks
- Pandas โ Data analysis
- DataFrame โ Table
- Series โ Column
๐งช Practice Exercise
Create a dataset using Pandas:
- Store patient names
- Store doses
- Display data
๐งช Mini Project
Create a simple patient dataset:
import pandas as pd
data = {
"Name": ["Alice", "Bob"],
"Dose": [500, 700]
}
df = pd.DataFrame(data)
print(df)
๐ MCQs
- Pandas is used for:
a) Gaming
b) Data analysis
c) Networking
d) Drawing
Answer: b - DataFrame represents:
a) List
b) Table
c) String
d) Loop
Answer: b - Which is better for dataset analysis?
a) CSV
b) NumPy
c) Pandas
d) None
Answer: c
โ FAQs
Why is Pandas important in pharmacy?
It helps in analyzing clinical, PK, and ADR datasets efficiently.
Can Pandas replace NumPy?
Pandas is built on NumPy, but it is more user-friendly for data analysis.
๐ฅ Download Pharma Dataset for Practice
Start analyzing real patient and ADR data.
โก Next Topic: Pandas Series & DataFrame โ
Recommended readings
- Introduction to Pandas (Why it is used in Pharma Data Analysis)
- Pandas Series & DataFrame (with patient & PK datasets)
- Reading CSV & Excel Files (PK datasets, ADR reports)
- Inspecting Data (head(), tail(), info(), describe())
- Data Cleaning & Missing Values (real clinical dataset problems)
- Filtering & Selecting Data (high dose, ADR filtering)
- Grouping & Aggregation (mean dose, ADR frequency)
Question Bank Unit 4: Data Handling with Pandas
For detailed information: Basics of Python Programming for Pharmaceutical Sciences