Pandas Series Flashcards

1
Q

What is an Panda Series ?

A

Panda Series Data Structure is an One Dimensional Array ,containing a sequence of values associated with labeled index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to create a series in Pandas ?

A

import pandas as pd
s1 = pd.Series([10,25,56,78])
print(s1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. How to print index information of pandas Series object
A

import pandas as pd
s1 = pd.Series([10,20,30,40])
print(s1.index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. How to know data type of pandas series ?
A

import pandas as pd
s1 = pd.Series([10,20,30,40])
print(s1.dtype)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to access data value from pandas series ?

A
We have three methods.
s1.values
s1[1]
for n in s1:
    print(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. How to create an Series object with labeled index in pandas,and present the object and index ?
A

import pandas as pd
s2 = pd.Series([110,20,30,40],[‘a’,’b’,’c’,’d’])
print(s2) # Presenting the object
print(s2.index) # presenting the index of Series object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

While creating a Series object ,it is necessary the length of values and index is same ?

A

Yes it is necessary no. of index and values should be same

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the data type attribute in Series object ?

A

It returns a data type of object
import pandas as pd
s1 = pd.Series([10,20,30,40])
print(s1.dtype)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the attribute in Series object which tells no. of items in Series Object ?

A

import pandas as pd
s1 = pd.Series([10,20,30,40])
print(s1.index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the major difference in lists and panda Series ?

A

In Series we have a option of labeling an index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How multiply or add a values to Series object ?

A
import pandas as pd
s3 = pd.Series([1,2,3,4,5])
s3 = s3 +10
print(s3)
s3 = s3 *3
print(s3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to present multiply and add of two pandas Series values ?

A
import pandas as pd
s3 = pd.Series([1,2,3,4,5])
s4 = pd.Series([5,4,3,2,1])
print(s3*s4)
print(s3+s4)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to use an identity operator in pandas Series ?

A
import pandas as pd
s3 = pd.Series([1,2,3,4,5])
print(2 in s3.values)
print(10 in s1)
if 4 in s3.values:
    print('True')
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to print pandas Series object values only ?

A

import pandas as pd
s3 = pd.Series([1,2,3,4,5])
print(s3.values)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Create a Series object of range 100, and assign value 4 to each ?

A

s5 = pd.Series(4,index = range(100))

print(s5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Create a Series object of labeled index a to f, and assighn value 4 to each ?

A

import pandas as pd
s5 = pd.Series(4,index = [‘a’,’b’,’c’,’d’,’e’,’f’])
print(s5)

17
Q

Create a Series Object and assigh numeric values,test values greator than 10 ?

A

import pandas as pd
s6=pd.Series([40,2,3,50,9,90,100,5,9,4,1])
print(s6[s6>10])
print(s6 > 10)

18
Q

Create a Series Object and assighn numeric values,present values only on certain condition ?

A

import pandas as pd
s6=pd.Series([40,2,3,50,9,90,100,5,9,4,1])
print(s6[s6>40])

19
Q

Create a Series Object and assigh numeric values,test values greator than 10 ,
on this testing condition create a filter?

A

We have two methods.
s6=pd.Series([40,2,3,50,9,90,100,5,9,4,1])
myfilter = s6 > 40
s6[myfilter]

myfilter2=s6[s6>10]
print(myfilter2)

20
Q

Create a Series Object and assigh numeric values,present values which are greator than mean of values in Series ?

A

import pandas as pd
s6=pd.Series([40,2,3,50,9,90,100,5,9,4,1],[‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’])
print(s6[s6>s6.mean()])

21
Q

Create a Series Object,create a dictionary,assgn dictionaty to series object,and name a Series Object ?

A

import pandas as pd
grades = {‘Marry’:94,’David’:80,’John’:95,’Sundy’:98}
s8=pd.Series(grades,name=’Grades’)
print(s8)

22
Q

Create a Series object of Dictionaty Data Structure ?

A

import pandas as pd
profile = {‘ID’:123,’Name’:’Hemant’,’Sex’:’Male’,’Age’:34}
s7=pd.Series(profile) # create a Series, uses dictionary key values as index
print(s7)
print(s7[‘Name’])

23
Q

Create a Series Object and name it ,assign numeric values?

A

import pandas as pd
s9=pd.Series([10,20,3,40],[‘a’,’b’,’c’,’d’],name=’Numeric Values’)
print(s9)

24
Q

Create a Series Object and assign numeric values, check ,If mean of series is greator than 10 or not ?

A

import pandas as pd
s6=pd.Series([40,2,3,50,9,90,100,5,9,4,1],[‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’])
print(s1.mean() > 10)

25
Q

Create a series named grades to store grades of an Student with name ?

A

import pandas as pd
grades = pd.Series([120,30,40],index=[‘Hemant’,’Sundy’,’Bella’])
print(grades)

26
Q

What are the parameters in pd.Series () method ?

A

index,names and dictionary