0% found this document useful (0 votes)
213 views3 pages

2a.pandas - Series

Pandas series are one-dimensional labeled arrays capable of holding any data type. A series can be created from a NumPy array, dictionary, scalar value, or by specifying an index for repeated data. Series support indexing by label to access individual elements.

Uploaded by

venkatesh m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
213 views3 pages

2a.pandas - Series

Pandas series are one-dimensional labeled arrays capable of holding any data type. A series can be created from a NumPy array, dictionary, scalar value, or by specifying an index for repeated data. Series support indexing by label to access individual elements.

Uploaded by

venkatesh m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1/20/22, 9:58 PM 2a.

Pandas - Series

In [2]:
# PANDAS

# it is a python package providing fast, flexible and Expressive data structures design
# pandas is top of numpy

# Pandas is build on two data structures 1) series 2) dataframe

# 1 ) Series : it is one dimensional labelled array capable of holding any datatype.

#Series(data,index=index)

# Series will be created in Array , Dictm , scalar value or constant

In [1]:
# Creating a series from ndarray

# import the pandas library and aliasing as pd

import pandas as pd

import numpy as np

In [ ]:
pd.read_csv

In [2]:
test = np.array(['s','o','c','i','a','l'])

test

Out[2]: array(['s', 'o', 'c', 'i', 'a', 'l'], dtype='<U1')

In [3]:
s = pd.Series(test)

Out[3]: 0 s

1 o

2 c

3 i

4 a

5 l

dtype: object

In [1]:
x= 2

y = 3

z = x+y

print(z)

a = z+ 2

Out[1]: 7

In [3]:
test = np.array(['s','o','c','i','a','l'])

s = pd.Series(test,index = [1,2,3,4,5,6])

file:///C:/Users/rgandyala/Downloads/2a.Pandas - Series.html 1/3


1/20/22, 9:58 PM 2a.Pandas - Series

Out[3]: 1 s

2 o

3 c

4 i

5 a

6 l

dtype: object

In [6]:
# Dict

# dictionary keys are taken in sorted order to construct index

test = {1:'a',2:'b'}

s = pd.Series(test)

Out[6]: 1 a

2 b

dtype: object

In [6]:
# Scalar

# if the data have repeated value then we have to match the index ( so index value will
x = pd.Series(2,index=[0,1,2])

Out[6]: 0 2

1 2

2 2

dtype: int64

In [7]:
# Series Indexing

s = pd.Series([1,2,3,4,5,6],index = ['s','o','c','i','a','l'])

Out[7]: s 1

o 2

c 3

i 4

a 5

l 6

dtype: int64

In [8]:
s['a']

Out[8]: 5

In [9]:
s['o']

Out[9]: 2

In [10]:
s['i']

Out[10]: 4

file:///C:/Users/rgandyala/Downloads/2a.Pandas - Series.html 2/3


1/20/22, 9:58 PM 2a.Pandas - Series

In [ ]:

In [ ]:

file:///C:/Users/rgandyala/Downloads/2a.Pandas - Series.html 3/3

You might also like