Day-2 Pandas Series Made Easy! Create Series Like a Pro (Multiple Methods)

In this tutorial, Akansha Yadav walks viewers through the concept of a pandas Series—a one‑dimensional data structure—and demonstrates eight distinct ways to create one in Python. She begins by sharing resource links (a GitHub repo with the code and a Telegram channel for free data‑analytics resources). Then, she systematically shows how to build a Series from a Python list, a dictionary, a scalar value with an explicit index, a NumPy ndarray, a generator expression, and finally by providing both custom data and custom index arrays. For each method she imports pandas (and NumPy where needed), defines the source data, constructs the Series with `pd.Series`, and prints the result to verify the output. The video concludes with five practice questions, an invitation for viewers to comment, and an offer to provide solutions via direct messages, encouraging community interaction and hands‑on learning.
Chapters
Ladies and gentlemen, hello everyone, welcome back to my YouTube channel. In today's video, we will be talking all about series, that how to create series, how pandas series has to be created, and what are the multiple ways using which you can create series to practice or to edit your data or to update your data. So before we started on our screen, I wanted to notify you with two things. First is that all the code that I am writing on my screen throughout the playlist, you will get the code link, it means the code file, and as in the GitHub. So you can get the GitHub repo link just below this video in the description section. Second is, if you wanted to learn data analytics or data scientist and you wanted to get the free resources for the same, then you can join my Telegram channel. I have added the link already in the description, so you can go and check that out. And the resources are totally free, of course. So just in one click you can join my Telegram channel. So let's get back on the screen and see how to create series. So basically, series is the one-dimensional data. So this— there are multiple ways to create series. So one of the way is to use a list, which is also one-dimensional data. You can use arrays as well. Second way to do is using a dictionary. Dictionary is also one-dimensional data. Third way is using a scalar value, any number like 5, 3, 7, or any number. Fourth is using a NumPy array. It means you have to import the NumPy library as well. Fifth is using a generator expression. Generator expression means using any for loop or any conditional statements type of things. And the last is that you have to specify both the things, data and index. So to create all these series, first I need is the pandas in my notebook. So first way we are going to see that how to create it using list. So first I have to import the pandas in my notebook. I am writing import pandas as pd. After that I have to create a data. So data is going to be either a list or an array. So I am creating it with a list. So I have created a list where I have placed 1, 2, 3, 4, 5 numbers. Then I am creating series using pd.Series where S is capital, keeping data variable in the brackets. Now I am printing it to check whether this is created or not. So on left-hand side we are getting the indexes, on the right-hand side we are getting the data. Second way to do the same is that using a dictionary. You can also create a series using dictionary. So first is you have to create a data. So in the data I am using the curly bracket which denotes that it is the dictionary. So now what I am doing is I am writing key-value pairs. In the place of the key I am writing maths and in the value I am writing 1, and so on. I have written 3 values: science and English, 1, 2, 3. Now I am creating series pd.Series as capital Data is equal to data1, like My data is in the variable data1. Now I have to print it to check whether we are getting the correct data or not. So we are getting it. The another way to do is using a scalar value. What I mean by the scalar value is any numeric number, like number basically. So scalar is equal to 5, I am writing. So in this case, when I am writing scalar is equal to 5, so what I am going to do is I have to write the indexes also. So if I am writing scalar is equal to 5, it means I have to give the 5 indexing. If I am writing scalar is equal to 3, it means I can give the 3 indexing. So make sure that both the values are the same. Now you have to write a variable saying that index is equal to index. Index is an attribute and you have to assign the indexes to that. Now on the left-hand side we are getting ABCD and on the right-hand side we are getting the scalar value 5. The fourth way to create a series is using the NumPy nd_array. It means the NumPy library we have to use over here. So first is I need to import the NumPy library in my notebook. So before creating a data, let's import the NumPy library. Import NumPy as np. I am giving it a nickname as an np. Now I am using NumPy array np.array method to create an array. Now I am going to just— let me replace the 9 one. Yeah, now I am to create a series. So within a variable, I am writing pd.Series as capital, data is equal to D2. Now printing create 3. Last way to do is, uh, not the last way, second last way to do is using the generator expression. In the place of the generator expression, what I am going to do is I am going to use the for loop. So I will be generating 5 numbers using for loop. So I am using a single line command, x for x in range 5, range 5 I am giving. And now I am going to create the same pd.Series as capital and writing the variable generator expression as in the data. Now I am printing the data, printing create 4. Once I have printed it, I am getting the data. Suppose I am changing the range to 15, so I will get 15 range. Now I don't want to change the range, I wanted to update the data like x 3 I'm writing. So the data is getting updated on the basis of the generator expression. The last way to do is using this specifying data and the index. So you— what you can do is you can specify data as well and the indexes as well. So now let's create a sample data. So first thing is we have to create the sample data. So I'm writing sample_data. Once we have written sample_data, 1, 2, 3, 4, 5. Now I am going to write the indexes. So just indexes, I am writing X, C, V, B, and last is the N. So now I have written the indexes as well. Now we have to create the series. So I'm writing any variable, we have already created create4, now it's create5.pd.series bracket. We are writing sample_data, index is equal to index. Just to make a difference between the index and in sample_index, I am writing sample_index as a variable. Now let's print. So that's how you can create series. So to create series, there are multiple ways and And these are all the ways. And these are 5 questions that you need to practice. And you can drop your suggestions or the things in the comment section. And also the solution of these practice exercises also you can DM me onto the LinkedIn. So these are the 5 questions which you can practice after watching this video. And don't forget to comment down your views or suggestion in below this video in the comment section. And for the solution of this file, you can DM me if you wanted to. If you want me to create the videos or the solution of these practice questions, then I am open to create that as well. So don't forget to comment down yours. Bye-bye.










