Pandas 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Series Data Structure

Series : A series is a Pandas data structure that


represent a one-dimentional array-like object
containing an array of data and an associated of
data labels, called its index.
Creating Series Objects
• A series types object can be created in many ways using
pandas librery’s Series().

1. Creating empty Series object with no parameter


S is in uppercase

<Series objects> = pandas.Series()

The above statement wil create an empty Series type object with
no values having default datatype which is float64.
2. Creating non-empty Series objects
To create a non-empty series object, you need to specify
argument for data and indexes as per following syntax.

<Series object > = pd.Series (data,index=idx)


idx = valid Numpy datatype
data = it is the data part of Series object, it can be one of the
following
(i) A Python sequence (ii) An ndarray
(iii) A Python (iv) A Scalar value
(i) Specify data as Python Sequence
<Series object > = pd.Series (any Python sequence)
(ii) Specify data as an ndarray

We can create a Series object from any ndarray created


from any function.
ser1 = pd.Series(np.arange(3,13,3.5))
(iii) Specify data as a Python Dictionary
(iii) Specify data as a Scalar Value
The data can be in the form of a single value or a scalar
value, but if data is a scalar value , then the index argument
must be provied.

You might also like