Once you move from basic Python into data science, machine learning, or AI, one of the first things you need to become comfortable with is working with tables of data. Most AI projects do not begin with a clever model or a complicated algorithm. They begin with a file. That file might contain customer information, house prices, medical measurements, product sales, sensor readings, website activity, exam results, or thousands of other kinds of records. Before a model can learn from any of that information, you need to know what the dataset contains, whether the values make sense, whether anything is missing, and which parts of the data are actually useful.
This is exactly where pandas becomes important. pandas is one of the most widely used Python libraries for working with structured data, and it gives you a practical way to load, inspect, filter, clean, and summarize tables without manually processing every row yourself. If you have ever worked with a spreadsheet, the basic idea will already feel familiar: you have rows, columns, values, and labels. The difference is that instead of clicking around with a mouse, you can inspect and manipulate the entire dataset using Python code.
In this article, you will learn the pandas skills that matter most when starting AI. You will load a CSV file into a DataFrame, inspect the first rows, check the size and column names, identify missing values, filter rows using conditions, and calculate useful summary statistics. The goal is not to teach every feature in pandas. pandas is a large library, and you could spend a long time exploring it. The goal here is to give you the practical workflow you will repeatedly use when preparing data for machine learning.
Why pandas Matters Before Machine Learning
Machine learning models need data, but real data is rarely clean and perfectly organized when you first receive it. A dataset may contain blank values, incorrect types, duplicated records, strange measurements, inconsistent labels, or columns that have nothing to do with the prediction you want to make. Even a dataset that looks fine at first glance can hide problems that will affect a model later.
Imagine a small student dataset stored like this:
name,age,hours_studied,attendance,exam_score
Anna,21,5.5,92,84
David,23,2.0,68,57
Maria,20,7.0,95,91
John,22,,81,73
Sofia,21,4.5,88,79
There are already several useful questions we could ask before doing anything with machine learning. We might want to know the average exam score, which student studied the most, whether attendance appears related to exam performance, and whether any values are missing. We may also want to filter the dataset to inspect only students with high scores or poor attendance. pandas allows us to answer all of those questions with very little code.
The important thing to understand is that pandas sits between raw data and the model. You usually use pandas to understand and prepare the dataset, then pass the cleaned and selected information into libraries such as scikit-learn, PyTorch, or TensorFlow. A strong model cannot compensate for data you have never properly inspected.
The DataFrame: The Table You Will Work With
The central object in pandas is called a DataFrame. You can think of a DataFrame as a programmable table containing rows and columns. It is similar to a worksheet in Excel, but because it lives inside Python, you can manipulate thousands or millions of values using code instead of manually editing cells.
Imagine a table like this:
name age hours_studied attendance exam_score
Anna 21 5.5 92 84
David 23 2.0 68 57
Maria 20 7.0 95 91
John 22 3.5 81 73
In this dataset, each row represents one student, while each column represents one type of information about that student. The same structure appears everywhere in data science. In a housing dataset, each row might represent one house and the columns might contain size, number of bedrooms, location, age, and sale price. In a medical dataset, each row might represent one patient while the columns contain measurements, symptoms, test results, and a diagnosis. In a sales dataset, each row could represent one transaction with columns for product, quantity, customer, date, and revenue. The meaning changes, but the table structure remains the same.
You will often see a DataFrame stored in a variable called df, which is simply short for DataFrame. Some people use names such as data, customers, or sales, but df is extremely common in tutorials and notebooks.
import pandas as pd
df = pd.read_csv("students.csv")
After this code runs, the variable df contains the table loaded from the file.
CSV Files: A Common Source of Data
One of the most common file formats you will encounter when learning data science is CSV. CSV stands for Comma-Separated Values, and the format is exactly what the name suggests: each line represents a row, while commas separate the values into columns.
A CSV file might contain:
name,age,hours_studied,attendance,exam_score
Anna,21,5.5,92,84
David,23,2.0,68,57
Maria,20,7.0,95,91
John,22,,81,73
Sofia,21,4.5,88,79
The first line normally contains the column names, while each following line contains one record. CSV files are popular because they are simple and supported almost everywhere. Data can be exported from Excel, Google Sheets, databases, analytics platforms, and business systems into CSV format, which makes it one of the easiest ways to move tabular data between different tools.
When you start exploring public datasets for machine learning, many of them will also be available as CSV files. That makes pd.read_csv() one of the pandas commands you will probably use more than almost anything else.
Importing pandas
pandas is almost always imported using the abbreviation pd.
import pandas as pd
The name pd is not required by Python; it is simply a convention that has become standard across the data science community. Because almost every tutorial and project uses the same abbreviation, it is worth following that convention. Once imported, pandas functions can be accessed through pd, which is why loading a CSV looks like pd.read_csv() rather than writing the full library name every time.
A normal starting point for a pandas script or notebook therefore looks like this:
import pandas as pd
df = pd.read_csv("students.csv")
Conceptually, the CSV file is the input, pandas reads it, creates a DataFrame, and stores that DataFrame in df.
Inspect the Dataset Before You Touch It
One of the best habits you can develop in data science is to inspect a dataset immediately after loading it. Do not assume that a file contains exactly what you expect just because you know its name or read a short description of it. Column names may be different, values may be missing, extra columns may exist, or the file may have been exported in an unexpected way.
The first method you will usually use is head().
print(df.head())
By default, head() displays the first five rows of the DataFrame. You might see something like this:
name age hours_studied attendance exam_score
0 Anna 21 5.5 92 84
1 David 23 2.0 68 57
2 Maria 20 7.0 95 91
3 John 22 NaN 81 73
4 Sofia 21 4.5 88 79
Even this tiny preview tells you a lot. You can confirm that the file loaded correctly, see the exact column names, get a feeling for the values inside each column, and notice obvious problems. In this example, the hours_studied value for John is shown as NaN, which tells us that information is missing.
You can control how many rows are displayed by passing a number to head().
print(df.head(3))
You can also inspect the final rows with tail().
print(df.tail())
These methods are simple, but they are extremely useful because they let you quickly confirm that the DataFrame looks the way you expect before you start performing larger operations.
Understanding Rows and Columns in Practice
A DataFrame has two dimensions: rows and columns, but what matters is how you interpret them. Rows normally represent individual observations, examples, events, or records, while columns describe characteristics of those records. If you are training a model to predict something, many of those columns may eventually become the information the model uses as input.
Consider the student dataset again. One row contains everything we know about Anna: her age, study hours, attendance, and exam score. The next row contains the same types of information for David. The columns define the structure shared by every student. Because every row follows the same layout, pandas can perform operations on entire columns without you manually looping through each student.
This becomes especially important in machine learning because columns often turn into features and targets. If you wanted to predict exam score using study hours and attendance, the columns hours_studied and attendance could become model inputs, while exam_score would become the value you want the model to predict.
Checking the Size of the Dataset
Before analyzing a dataset, it is useful to know how large it actually is. pandas provides the shape attribute for this.
print(df.shape)
Suppose the result is:
(1000, 5)
This tells you that the DataFrame contains 1,000 rows and 5 columns. The first number is always the number of rows, while the second number is the number of columns.
The shape gives you immediate context. A dataset with 20 rows is very different from one with 2 million rows. It also helps you catch unexpected problems. If someone tells you that a file contains 50,000 records and df.shape shows only 500 rows, something may have gone wrong during loading or exporting.
You can access the values separately if needed:
rows = df.shape[0]
columns = df.shape[1]
print("Rows:", rows)
print("Columns:", columns)
Checking Column Names
Column names are important because you use them constantly when selecting, filtering, and transforming data. You can inspect them with:
print(df.columns)
For the student dataset, you might see:
Index(['name', 'age', 'hours_studied', 'attendance', 'exam_score'], dtype='object')
The main information you care about is the list of column names. Checking them early can prevent frustrating errors later because column names must match exactly. You might expect a column to be called exam_score, but the file may contain Exam Score, examScore, or even exam_score with an invisible trailing space.
Real-world datasets are often less tidy than tutorial datasets, so getting into the habit of checking df.columns can save you time.
Selecting a Single Column
A large part of pandas work involves selecting specific parts of a DataFrame. To select one column, place its name inside square brackets.
scores = df["exam_score"]
You can inspect it directly:
print(df["exam_score"])
The output may look like this:
0 84
1 57
2 91
3 73
4 79
Name: exam_score, dtype: int64
A single DataFrame column is technically a pandas object called a Series. You do not need to spend much time worrying about the distinction yet. What matters is that a Series behaves like one labeled column of values, and pandas provides many useful methods for working with it.
For example, you can calculate the average directly:
average_score = df["exam_score"].mean()
Or the highest value:
highest_score = df["exam_score"].max()
Instead of manually looping through the numbers, pandas performs the operation on the entire column.
Selecting Multiple Columns
You can also create a smaller DataFrame by selecting several columns at once. To do that, pass a list of column names.
selected = df[
["hours_studied", "attendance", "exam_score"]
]
A shorter version is:
selected = df[["hours_studied", "attendance", "exam_score"]]
This becomes extremely important in machine learning because you rarely use every column in a dataset. Some columns may be identifiers, names, timestamps, or information unrelated to the prediction problem.
For example, if you want to predict exam score from study hours and attendance, you might write:
X = df[["hours_studied", "attendance"]]
y = df["exam_score"]
The variable X contains the input features, while y contains the target. You will see this pattern constantly when you start working with scikit-learn.
Getting a Structural Overview With info()
Looking at the first few rows is useful, but sometimes you want a compact summary of the entire structure of the dataset. For that, pandas provides info().
df.info()
You may see output similar to this:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 5 columns):
# Column Non-Null Count Dtype
0 name 5 non-null object
1 age 5 non-null int64
2 hours_studied 4 non-null float64
3 attendance 5 non-null int64
4 exam_score 5 non-null int64
This is one of the most useful inspection tools in pandas because it gives you several pieces of information at once. You can see how many rows and columns exist, how many non-missing values each column contains, and what data type pandas assigned to every column.
In this example, hours_studied contains only four non-null values even though the dataset has five rows. That immediately tells us that one value is missing. We can also see that name is stored as text, while the other columns are numerical.
Checking Data Types
Data types matter because machine learning models eventually need numerical information in specific formats. A column that looks numeric to you may accidentally be stored as text because of one unusual value, and that can cause problems later.
You can inspect the data type of every column with:
print(df.dtypes)
You might see:
name object
age int64
hours_studied float64
attendance int64
exam_score int64
Here, int64 represents whole numbers, float64 represents decimal numbers, and object commonly represents text in many pandas datasets. You do not need to memorize pandas data types, but you should learn to notice when something looks wrong. If a salary column is stored as object rather than a numerical type, for example, you should investigate why before using it in a model.
A common reason for incorrect types is that the dataset contains a value such as "unknown", "N/A", or a currency symbol mixed into an otherwise numerical column.
Missing Values Are Part of Real Data
Missing data is extremely common. A user may leave a form field blank, a sensor may fail to record a measurement, an old database entry may not contain information that newer records include, or data may simply be unavailable.
pandas often represents missing numerical values as:
NaN
Suppose your table contains:
name age hours_studied attendance exam_score
Anna 21 5.5 92 84
David 23 2.0 68 57
Maria 20 7.0 95 91
John 22 NaN 81 73
Sofia 21 4.5 88 79
The missing value itself is not automatically a disaster. What matters is that you detect it and make a sensible decision about how to handle it. The wrong approach is to ignore missing values and hope the machine learning library will somehow understand what you intended.
Finding Missing Values
You can ask pandas whether each value is missing using:
df.isnull()
That returns a DataFrame filled with True and False values, but for a large dataset it is not very useful to read directly. A much better approach is to combine it with sum().
print(df.isnull().sum())
You might get:
name 0
age 0
hours_studied 1
attendance 0
exam_score 0
dtype: int64
This tells you exactly how many missing values appear in each column. In this case, only hours_studied has missing data, and it is missing in one row.
This check is so useful that it should become part of your standard inspection routine whenever you load a new dataset.
Handling Missing Values
Once you find missing values, you need to decide what to do with them. There is no universal answer because the correct choice depends on the dataset, the amount of missing data, and what the column actually represents.
One option is to remove rows that contain missing values:
clean_df = df.dropna()
This may be reasonable if only a tiny number of rows are incomplete and you have a very large dataset. However, if the dataset is small or many rows contain missing values, deleting them could remove a significant amount of useful information.
Another option is to replace missing values with something reasonable. For a numerical column, you might fill missing values with the average:
average_hours = df["hours_studied"].mean()
df["hours_studied"] = df["hours_studied"].fillna(
average_hours
)
This technique is called imputation. Mean imputation is easy to understand, but it should not become an automatic habit. In some datasets, the median may be more appropriate. In others, a missing value may have a meaningful reason and should be handled differently. The important lesson at this stage is not that one method is always correct, but that missing data needs deliberate treatment.
Filtering Rows With Conditions
Filtering is one of the most useful things you can do with pandas because it allows you to ask specific questions about the dataset. Suppose you want to see only students who scored at least 80.
high_scores = df[df["exam_score"] >= 80]
print(high_scores)
pandas evaluates the condition for every row and keeps only the rows where the condition is true. This makes it easy to investigate specific groups without changing the original dataset.
You could filter by attendance:
good_attendance = df[df["attendance"] >= 85]
Or study time:
regular_studiers = df[df["hours_studied"] >= 5]
Filtering becomes incredibly useful during exploratory data analysis because you can quickly investigate unusual groups, compare categories, or isolate records that match certain criteria.
Filtering With Multiple Conditions
Real questions often involve more than one condition. Suppose you want students who scored at least 80 and had attendance of at least 90 percent.
strong_students = df[
(df["exam_score"] >= 80)
& (df["attendance"] >= 90)
]
The & symbol means both conditions must be true. For an OR condition, pandas uses |.
selected_students = df[
(df["exam_score"] >= 90)
| (df["attendance"] >= 95)
]
One detail worth remembering is that pandas conditions should generally be wrapped in parentheses when you combine them. It makes the code clearer and avoids problems with how Python interprets the expression.
These filters become useful when you want to investigate questions such as whether highly engaged students also perform better, which customers meet certain conditions, or which transactions exceed particular limits.
Filtering Text and Categories
Filters are not limited to numerical data. If your dataset contains text or categorical columns, you can filter those too.
Imagine a dataset with a city column:
name city
Anna Athens
David London
Maria Athens
John Berlin
You can select only rows from Athens:
athens_students = df[df["city"] == "Athens"]
Or exclude them:
other_students = df[df["city"] != "Athens"]
This same pattern works for categories such as product type, department, customer segment, diagnosis, country, subscription plan, or class label. Categorical filtering is particularly useful when you want to compare different groups before deciding how they should be handled in a model.
Sorting Data to Find High and Low Values
Sorting can make a dataset easier to understand, especially when you want to inspect the largest or smallest values.
To sort by exam score:
sorted_df = df.sort_values("exam_score")
print(sorted_df)
By default, pandas sorts from smallest to largest. If you want the highest scores first, use:
sorted_df = df.sort_values(
"exam_score",
ascending=False
)
Sorting is useful when looking for extremes, rankings, or suspicious values. If you have a column containing transaction amounts, for example, sorting from largest to smallest may quickly reveal unusually large transactions that deserve further inspection.
You can also sort using more than one column:
sorted_df = df.sort_values(
["exam_score", "attendance"],
ascending=False
)
This means pandas will primarily sort by exam score and use attendance to order rows when necessary.
Summary Statistics: Understand the Numbers Before Modeling
One of the fastest ways to understand the numerical columns in a dataset is with describe().
print(df.describe())
You may see something like:
age hours_studied attendance exam_score
count 5.0 4.000000 5.000000 5.000000
mean 21.4 4.750000 84.800000 76.800000
std 1.1 2.101587 10.639549 12.853015
min 20.0 2.000000 68.000000 57.000000
25% 21.0 3.875000 81.000000 73.000000
50% 21.0 5.000000 88.000000 79.000000
75% 22.0 5.875000 92.000000 84.000000
max 23.0 7.000000 95.000000 91.000000
You do not need to memorize every statistic immediately, but several of them are especially useful from the beginning. count tells you how many non-missing values are available, mean gives the average, min gives the smallest value, and max gives the largest. The quartiles and standard deviation become more useful as you learn more statistics because they help describe the spread and distribution of the data.
The important point is that describe() lets you inspect the general behavior of multiple numerical columns with a single command. That can reveal problems very quickly.
Why Summary Statistics Can Catch Bad Data
Suppose your dataset contains an age column and describe() shows:
min -4
max 420
pandas will not tell you that those values are ridiculous for ordinary human ages. From pandas' perspective, they are simply numbers. It is your job to notice that something does not make sense.
The same problem can happen with salaries, temperatures, prices, measurements, dates, and almost every other type of numerical information. If most salaries are between 30,000 and 100,000 but the maximum is 999,999,999, that value deserves investigation. It may be genuine, but it may also be a data-entry error, a placeholder, or a formatting problem.
This is one reason exploratory data analysis is so important. Machine learning models are extremely good at learning patterns from the data you give them, including patterns caused by mistakes. A model will not automatically understand that an age of 420 is probably incorrect.
Calculating Statistics for a Single Column
You can also calculate individual statistics directly when you only care about one column.
For example:
average_score = df["exam_score"].mean()
minimum_score = df["exam_score"].min()
maximum_score = df["exam_score"].max()
median_score = df["exam_score"].median()
You can display them together:
print("Average:", average_score)
print("Minimum:", minimum_score)
print("Maximum:", maximum_score)
print("Median:", median_score)
These methods are simple but extremely useful. Before training a model, you often want to know the typical value of a column, the range of values it contains, and whether there are extreme results that should be inspected more closely.
Counting Categories
Not every column contains numbers. Some columns contain categories such as department, country, product type, diagnosis, or subscription plan. For these columns, calculating an average would make no sense, so pandas provides other useful tools.
Suppose your dataset contains a department column. You can count how many records belong to each department using:
print(df["department"].value_counts())
You might see:
Sales 120
Engineering 85
Marketing 42
HR 19
This gives you an immediate picture of the distribution of categories. You may discover that one group dominates the dataset while another appears only a few times, which can become important when training a model.
You can also inspect the distinct values with:
print(df["department"].unique())
That might return:
['Sales' 'Engineering' 'Marketing' 'HR']
This is especially useful when you receive a new dataset and want to understand what categories actually exist rather than assuming you already know them.
A Practical pandas Inspection Workflow
When you receive a new dataset, it helps to have a repeatable process instead of randomly running commands. A good first inspection can be surprisingly small and still tell you a lot.
Start by loading the file:
import pandas as pd
df = pd.read_csv("students.csv")
Then inspect the first few rows:
print(df.head())
Check the dimensions:
print(df.shape)
Inspect the column names:
print(df.columns)
Get a structural overview:
df.info()
Check missing values:
print(df.isnull().sum())
Finally, inspect summary statistics:
print(df.describe())
Those few commands answer many of the most important first questions. You learn what the data looks like, how large it is, which columns are available, what types of values they contain, whether anything is missing, and whether the numerical ranges appear reasonable.
This sequence is worth remembering because you can apply it to almost any tabular dataset.
Practical Coding: Load and Inspect a Small CSV Dataset
Let's put the main ideas together using a small dataset called students.csv.
Imagine the file contains:
name,age,hours_studied,attendance,exam_score
Anna,21,5.5,92,84
David,23,2.0,68,57
Maria,20,7.0,95,91
John,22,,81,73
Sofia,21,4.5,88,79
Lucas,24,3.0,74,64
Elena,20,6.5,97,94
We begin by loading it:
import pandas as pd
df = pd.read_csv("students.csv")
Now inspect the first rows:
print(df.head())
Next, check the column names and size:
print("Columns:")
print(df.columns)
print("Shape:")
print(df.shape)
Then inspect the structure and data types:
df.info()
Now check missing values:
print("Missing values:")
print(df.isnull().sum())
Finally, calculate a general statistical summary:
print("Summary statistics:")
print(df.describe())
With only a few commands, you now know that the dataset contains seven students and five columns, you can see the exact names of the available fields, and you know that hours_studied contains one missing value. You also have the average, minimum, maximum, and other descriptive statistics for the numerical columns.
That is already enough information to begin asking more specific questions.
Filtering the Student Dataset
Suppose you want to inspect students who scored at least 80.
high_scores = df[df["exam_score"] >= 80]
print(high_scores)
Now suppose you are interested in students with attendance of at least 90 percent:
high_attendance = df[df["attendance"] >= 90]
print(high_attendance)
You can combine those conditions to find students who performed strongly and also attended regularly:
strong_students = df[
(df["exam_score"] >= 80)
& (df["attendance"] >= 90)
]
print(strong_students)
This is where pandas starts becoming much more than a way to display tables. You are using code to ask questions about the dataset and immediately create smaller groups that match the conditions you care about.
Finding the Highest and Lowest Values
If you only want the highest exam score, use:
highest_score = df["exam_score"].max()
print(highest_score)
To find the lowest:
lowest_score = df["exam_score"].min()
print(lowest_score)
But sometimes the number alone is not enough. You may want to know which student achieved the highest score. One simple method is to sort the dataset:
top_student = df.sort_values(
"exam_score",
ascending=False
).head(1)
print(top_student)
This returns the entire row, which means you can see the student's name, age, attendance, study hours, and score together.
That difference is important. Sometimes you are interested in a value, while other times you are interested in the record connected to that value.
Connecting pandas to Machine Learning
Once you can confidently work with DataFrames, machine learning code becomes much easier to understand because pandas is often used to prepare the exact inputs a model needs.
Suppose you want to predict exam scores using study hours and attendance. You could select the feature columns like this:
X = df[["hours_studied", "attendance"]]
Then select the target:
y = df["exam_score"]
Before doing that, however, you would probably need to deal with the missing value in hours_studied.
One simple approach would be:
df["hours_studied"] = df["hours_studied"].fillna(
df["hours_studied"].mean()
)
Then a basic machine learning workflow could continue:
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
X = df[["hours_studied", "attendance"]]
y = df["exam_score"]
X_train, X_test, y_train, y_test = train_test_split(
X,
y,
test_size=0.2,
random_state=42
)
model = LinearRegression()
model.fit(X_train, y_train)
predictions = model.predict(X_test)
The point here is not to study linear regression yet. Look instead at everything that happened before the model was trained. The file was loaded, the missing value was handled, relevant columns were selected, and the dataset was separated into inputs and a target. pandas is doing the data work that makes the machine learning stage possible.
Mini Challenge: Find the Average, Minimum, and Maximum
Using the exam_score column from the student dataset, find three values: the average score, the minimum score, and the maximum score.
Try to write the solution yourself first. You only need three pandas methods: mean(), min(), and max().
A complete solution looks like this:
average_score = df["exam_score"].mean()
minimum_score = df["exam_score"].min()
maximum_score = df["exam_score"].max()
print("Average:", average_score)
print("Minimum:", minimum_score)
print("Maximum:", maximum_score)
You could also write it more directly:
print("Average:", df["exam_score"].mean())
print("Minimum:", df["exam_score"].min())
print("Maximum:", df["exam_score"].max())
The challenge itself is simple, but the habit behind it matters. Before trying to build a model, you should understand the numerical columns you plan to use. Knowing the average gives you a sense of the typical value, while the minimum and maximum give you a quick look at the range.
Do Not Trust Data Just Because It Loaded Successfully
A dataset can load perfectly into pandas and still contain terrible data. pandas is not going to stop you because a value looks unrealistic. If your age column contains -5 or 400, pandas will usually accept those numbers without complaint. Whether they make sense depends on the real-world meaning of the dataset.
The same applies to almost every type of information. A salary of 999999999 may be a real outlier, but it could also be an error. A temperature of 700 might be completely impossible in one dataset and completely normal in another. A missing category could indicate poor data collection or something meaningful about the record itself.
This is why data analysis involves judgment, not just commands. pandas gives you the tools to reveal what is inside a dataset, but you still need to ask whether those values make sense.
pandas Is Really About Asking Better Questions
It is useful to stop thinking of pandas as a collection of commands and instead think of it as a way to ask questions about data.
How many records do I have?
print(df.shape[0])
What columns are available?
print(df.columns)
Are values missing?
print(df.isnull().sum())
What is the average score?
print(df["exam_score"].mean())
Which students scored above 80?
print(df[df["exam_score"] > 80])
What is the highest attendance?
print(df["attendance"].max())
What do the numerical columns generally look like?
print(df.describe())
Once you become comfortable asking questions this way, pandas starts feeling much more natural. You are no longer memorizing syntax for its own sake. You are using Python to investigate real information.
What You Should Know Before Moving On
You do not need to master the entire pandas library before progressing into machine learning. pandas contains far more functionality than you need at the beginning, and you will naturally learn more of it as your projects become more complicated.
What you should be comfortable with is the basic workflow. You should be able to load a CSV file, inspect the first rows, check the dimensions, identify the available columns, select one or several columns, filter rows, find missing values, inspect data types, and calculate basic statistics. You should also understand that the DataFrame is the main table structure you will work with and that rows normally represent individual records while columns represent different pieces of information about those records.
A small collection of commands gets you surprisingly far:
import pandas as pd
df = pd.read_csv("data.csv")
print(df.head())
print(df.shape)
print(df.columns)
df.info()
print(df.isnull().sum())
print(df.describe())
Then, once you understand the structure, you can begin asking more targeted questions:
print(df["score"].mean())
high_scores = df[df["score"] >= 80]
print(high_scores)
That is already enough pandas to begin working with many beginner machine learning datasets.
Final Thoughts
Learning pandas is one of the points where Python begins to feel like a serious AI tool rather than just a programming language. You can take a raw file containing thousands of records and quickly understand its structure, isolate useful columns, find missing information, calculate statistics, filter interesting groups, and prepare the data for a machine learning model.
The most important skill is not memorizing every pandas function. It is developing a reliable way of approaching unfamiliar data. Load the dataset and inspect it. Check the size and column names. Look at the data types. Search for missing values. Calculate summary statistics. Filter interesting records. Question values that look suspicious. Only after you understand what you are working with should you start building a model.
Machine learning depends heavily on the quality and structure of its data. pandas gives you the tools to understand that data before the model ever sees it, which is why it is one of the first libraries every AI learner should become genuinely comfortable using.