Python Libraries & Package Installation Explained (pip, Pandas, NumPy for Pharmacy Students)
Python becomes powerful through its libraries. These libraries help perform complex tasks such as data analysis, numerical computation, and visualization, which are essential in pharmaceutical sciences.
π· What is a Python Library?
A library is a collection of pre-written code that can be reused to perform specific tasks.
π· Types of Libraries
- Standard Libraries β Built into Python (math, random)
- Third-party Libraries β Installed separately (pandas, numpy)
π· What is pip?
pip is Pythonβs package manager used to install and manage libraries.
pip install pandas
π· Installing Libraries
π Install Pandas
pip install pandas
π Install NumPy
pip install numpy
π· Importing Libraries
import pandas as pd import numpy as np
If no error occurs, the library is installed successfully.
π Pharmaceutical Applications
- Pandas β Handling clinical and ADR datasets
- NumPy β Numerical calculations (dose, PK modeling)
- Matplotlib β Graphs (drug concentration-time)
π Pharma Data Example
import numpy as np
dose = np.array([500, 650, 400])
average = np.mean(dose)
print("Average Dose:", average)
π· Uninstalling Libraries
pip uninstall pandas
π· Viewing Installed Packages
pip list
π§ Memory Tricks
- pip = Python Install Packages
- import = Use the library
- NumPy β Numbers
- Pandas β Data tables
π§ͺ Practice Exercise
Install NumPy and calculate:
- Mean of drug doses
- Total dose administered
π MCQs
- pip is used for:
a) Writing code
b) Installing libraries
c) Debugging
d) Compiling
Answer: b - Which library is used for data analysis?
a) NumPy
b) Pandas
c) Math
d) Random
Answer: b - Which library is used for numerical operations?
a) Pandas
b) NumPy
c) Matplotlib
d) OS
Answer: b
β FAQs
Why are Python libraries important?
They simplify complex tasks like data analysis and modeling.
Which libraries are most useful in pharmacy?
Pandas, NumPy, and Matplotlib are widely used.
π₯ Download Pharma Dataset Practice Files
Practice real-world pharmaceutical data analysis.
β‘ Next Topic: Control Structures (if, loops) β
Unit 1 Blog Series:
- Installing Python
- Installing IDEs like Jupyter, VS Code, PyCharm
- Variables and Data types in Python
- Operators in Python
- Input & Output
- String Manipulation
- Libraries in Python (You are on this page page)
Question Bank : Unit 1 Python Programming Basics
For more details: Basics of Python Programming for Pharmaceutical Sciences (Theory)