Paath.online blog
Are NumPy and Pandas Required for Generative AI?
By Mohit Agarwal, Paath.online10 min read
Yes—for anyone who wants to learn generative AI properly and build projects beyond a one-file chatbot. They are not required to send a prompt to an LLM, but NumPy and Pandas are the practical bridge between Python, data, embeddings, RAG, and reliable evaluation.
The short answer: yes for learning, not always for every line of code
A simple generative-AI application can work without either library. For example, a Python script can send a string to an LLM API and print the reply. But that is only the interface layer. Once an application works with many documents, embeddings, user feedback, test questions, costs, or retrieval results, data handling becomes central. That is where NumPy and Pandas pay off.
So the accurate version of “yes” is: NumPy and Pandas are not strict prerequisites for using GenAI tools, but they are essential supporting skills for understanding and building useful GenAI systems. NumPy builds the numerical intuition; Pandas makes the surrounding data workflow manageable.
Why NumPy matters: embeddings are numbers, not magic
Language models read text, but systems often store the meaning of text as an embedding: a long list of numbers. A sentence, paragraph, or product description is converted into a vector. Similar vectors tend to represent similar meanings. NumPy helps you understand these vectors, their dimensions, and the operations used to compare them.
import numpy as np
query = np.array([0.2, 0.8, 0.1])
document = np.array([0.3, 0.7, 0.2])
similarity = np.dot(query, document) / (
np.linalg.norm(query) * np.linalg.norm(document)
)
print(round(float(similarity), 3))You do not need to calculate cosine similarity by hand in every project—vector databases and AI libraries often do it for you. Still, knowing what an array, vector, dimension, dot product, and normalization mean helps you diagnose poor search results and make informed design choices.
Why Pandas matters: GenAI projects are surrounded by messy data
Pandas is not normally inside the LLM itself. It is the workbench around the model. It can load a CSV of support questions, remove blank rows, inspect document metadata, group evaluation results, and export a clean report. These tasks are common in retrieval-augmented generation (RAG), fine-tuning preparation, and product analytics.
- RAG: clean document titles, sources, tags, and chunk metadata before indexing.
- Evaluation: compare prompts, answers, latency, cost, and human ratings in one table.
- Fine-tuning preparation: inspect examples, find duplicates, and validate required fields.
- Operations: review feedback and identify the topics where an assistant fails most often.
Where each library fits in a GenAI workflow
| Stage | Useful skill | Why it helps |
|---|---|---|
| Prototype a chat app | Core Python | Make API calls, manage prompts, and handle responses. |
| Prepare documents | Pandas | Clean rows, check missing values, and preserve metadata. |
| Create and compare embeddings | NumPy | Understand arrays, shapes, similarity, and batching. |
| Build RAG | Both | Manage document tables and reason about vector retrieval. |
| Evaluate quality | Pandas | Aggregate test cases, scores, cost, and reviewer feedback. |
| Train or serve a model | NumPy concepts + PyTorch | Tensor frameworks handle the heavy computation, built on similar numerical ideas. |
A useful distinction: NumPy/Pandas vs PyTorch
Beginners sometimes hear that modern AI uses PyTorch or TensorFlow and conclude that NumPy and Pandas do not matter. That skips an important layer. PyTorch is designed for tensors, automatic differentiation, GPUs, and neural-network training. NumPy is the simpler foundation for thinking about numerical arrays; Pandas is specialized for labelled, tabular data. They solve different problems and often appear in the same project.
Learn the concepts with NumPy, organize real-world records with Pandas, and use PyTorch when you need neural-network training or efficient tensor computation.
What to learn first: a practical sequence
- Learn core Python: variables, functions, lists, dictionaries, files, and virtual environments.
- Build one small LLM API project so the goal is concrete.
- Learn NumPy arrays, shapes, indexing, vectorization, and basic linear algebra intuition.
- Learn Pandas DataFrames: loading CSV files, filtering, missing values, grouping, and merging.
- Build a small RAG or evaluation project that uses both.
- Then move to PyTorch, model APIs, orchestration, or advanced retrieval as your goal requires.
If you are completely new to Python, begin with our Python roadmap for beginners. If you already know Python syntax, the NumPy and Pandas 20–22 session roadmap is a sensible next step before tackling a RAG project.
The bottom line
Treat NumPy and Pandas as core GenAI literacy, not as a gate you must pass before writing your first prompt. You can start experimenting today without them. But to understand embeddings, prepare trustworthy data, evaluate answers, and build systems that work beyond a demo, learning both is absolutely worth it.