Series() in pandas Python by R4R Team

Series :
-series is one dimensional array defined in pandas library that can be used to store any data type.

Syntax-

pandas.Series(data,index)

-Here data can be
1. scalar value like string,integer,float
2. python dictionary
3. Ndarray

Series with scalar value-


program-

import pandas

print("Enter stringn")
s=input()
a=pandas.Series(s)
print("After pandas seriesn",a)
print("")
#series with string
print(pandas.Series("string"))
#series with integer number
print(pandas.Series(8))
#serise with float number
print(pandas.Series(8.80))


output-

Enter string
programming
After pandas series
0programming
dtype: object

0string
dtype: object
08
dtype: int64
08.8
dtype: float64

-In this program, we take a input of the string and pass in the Series() function then this series function return that string with the index value as shown in above output.
-similarly, we pass integer and float number in the series() function, then it return number with the index value.




Leave a Comment:
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!