Series is one-dimensional labeled array in Python Pandas which is capable of holding data of any type i.e. integer, float, characters, etc. The axis labels are collectively called index.
How Series can be Created?
It can be
created using list, numpy arrays, from dictionaries, from scaler objects, etc.
Let us explore it one by one.
Syntax:-
Import
pandas as pd
Pd.Series(data, index, dtype)
Where pd is
pandas alias, Series is Function through which we create it Series, data is the
data we are creating, index is index of data and dtype is type of the data.
1. Create Series from Python List:-
Pandas
Series can be created by Python List. We can create python list and there after
call Python’s Pandas Series function to convert List into Series.
Let us
understand it by Code:-
Explanation:-
2. Create Pandas Series by passing values:-
Syntax:-
3. Create an Empty Series:-
4. Create Series from Numpy Arrays:-
Note:-
Output:-
Conclusion:-
5. Create a Series by Python Dictionary
In the next Post we will discuss about how to access data from series?
I hope you loved this post. Kindly Subscribe to our Youtube channel - Codin India
where we will learn Data Science with Python in Hindi and many more.
If you want to learn Data Science in Hindi - Data Science Full Course in Hindi
If you want to learn Numpy in Hindi - NumPy Tutorial
If you want to learn Full Stack web development in Hindi - Full Stack Web Development in Hindi
If you want to learn Python Programming - Python Programming in Hindi
Comments
Post a Comment