CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickAcademy Python · 8 min · free

Pandas Series

8 min4 KwickClipsFull text belowFree
Next lesson →Kajal Ma'am (MCA), teaching since 2004Remembered in this browser

Learn the Pandas Series for Class 12 Informatics Practices: four ways to create one, its attributes, indexing and slicing, and maths on it. A Series is labelled one-dimensional data, so every value carries a label called its index.

Follows the syllabus of: CBSE Class 12 Informatics Practices (065)

On screen in this lesson

What is Pandas?

Pandas is a Python library for working with data
Install it once with pip install pandas
Import it as pd in every program
Two main structures: Series and DataFrame

A Series: labels and values

Index (label)ValuePosition
Riya880
Aman751
Neha642

Quick recap

Series: labelled one dimensional data
Create from a list, dictionary, scalar or ndarray
size, shape, dtype, empty, index and values are attributes
Label slices include the end; position slices do not
Maths matches labels; missing labels give NaN

Quick answers

Does a label slice include the end label?

Yes. A label slice includes it, but a position slice stops before it.

Why did adding two Series give NaN?

Pandas matches by label, not position, so a label present in only one Series has no pair.

KwickClips from this lesson

Short clips, one idea each. Good for revision the night before.

The full lesson, in text

Hello students, welcome to Kwickprep. A list gives your marks, but can it tell you whose marks they are? A Series can. Today we will learn what a Series is and four ways to create one. Then we will pick values from it and do maths on it.

First, a few words about Pandas. Pandas is a library, which means a ready collection of code that we add to Python for working with tables of data. You install it once using the command pip install pandas. In every program, we import it and give it the short name P D. Pandas has two main data structures, the Series and the DataFrame, and today is all about the Series.

A Series is labelled, one dimensional data. One dimensional means the values sit in a single column, one after another. Each value has a label called the index, like Riya, and the value, like eighty eight. Every value also keeps a position number, starting from zero. So Aman has marks seventy five at position one. Neha has sixty four at position two.

The simplest way to create a Series is from a list. We write pandas dot Series, with a capital S, and pass the list. We did not give any labels, so Pandas uses the default index zero, one and two. The left column is the index and the right column is the values. The last line says int sixty four, which tells us the values are whole numbers.

Now we give our own labels using index equals names. The list names has Riya, Aman and Neha. Now each mark sits next to the student it belongs to. The number of labels must match the number of values. If they do not match, Python gives a value error.

A dictionary already has labels, so it makes a Series very easily. Think of a cricket scoreboard. The keys, the player names, become the index. The values, the runs, become the values of the Series. So Rohit gets forty five and Virat gets eighty two.

A scalar is a single value, like the number twenty. Suppose the canteen charges twenty rupees for tea every day. When we create a Series from a scalar, we must give an index. Pandas then repeats the same value for every label. So Monday, Tuesday and Wednesday all get twenty.

The book calls it an N D array. It simply means a NumPy array, the fast array from the NumPy library. We import NumPy with its usual short name. Here the array holds three recharge plan prices. Plan A costs one hundred ninety nine rupees, plan B two hundred ninety nine, and plan C three hundred ninety nine. We pass the array to pandas dot Series with our own labels as the index, just like a list.

An attribute is a fact about the Series that we read with a dot, and without brackets. Our Series is called marks, and the second argument is the index. Size gives the number of values, which is three. Shape gives the same count inside brackets. D type gives the type of the values. Empty is True only when the Series has no values. Index gives the labels, and values gives the data.

Indexing means picking values out of a Series. Marks of Aman uses the label and gives seventy five. Marks dot eye lock of two uses the position and gives sixty four, Neha's marks. To pick many values, put a list of labels inside the square brackets. That returns a smaller Series. Books also write marks of two for a position, but newer Pandas prefers eye lock when the labels are names.

Slicing takes a range of values with a colon. Marks of zero colon two uses positions, and like a list, it stops before position two. So we get Riya and Aman. Now look at the label slice, Riya colon Aman. Pause and predict. Is Aman included? Yes. A label slice includes the end label, but a position slice does not. Board exams love this difference.

Real data can have thousands of rows, so we peek at a few. Head gives the first few values, and tail gives the last few. Here runs dot head of two gives twelve and forty five. Tail of two gives eighty eight and thirty, with their index, three and four. With empty brackets, head and tail give five values each.

Maths on a Series works on every value at once, with no loop. Test one holds marks in the first test, and test two holds marks in the second. Test one plus test two adds the marks label by label. So Om gets forty plus forty five, which is eighty five. Test one into two doubles every value.

Here is the trap. Pandas matches values by label, not by position. Only Anu is in both Series, so only Anu gets a real total, sixty five. Om and Jo each appear in just one Series, so they get N a N, which means Not a Number, a missing value. The result is also sorted by label. The type becomes float, because N a N is a decimal value.

To avoid N a N, use the add method with fill value equals zero. A missing mark is treated as zero before adding. So Om gets forty and Jo gets forty two. There are also sub, mul and div methods for minus, multiply and divide. You can also filter with a condition, like marks where marks is greater than seventy.

Let us revise what we learned today. A Series is labelled, one dimensional data. You can create it from a list, a dictionary, a scalar or a NumPy array. Size, shape, D type, empty, index and values are its attributes. A label slice includes the end, but a position slice does not. And maths matches labels, so a missing label gives N a N. Try making a Series of your own marks and add two tests together.

Courses that teach this

CourseUnit
CBSE Class 12 Informatics Practices (065)Data Handling using Pandas -I

Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.

Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →