Pandas Flashcards

1
Q

What is Pandas?

A

It is module/ function of python that is used to store data in the form of dataframe fore easy operations

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

Data Structure ?

A

It is an organized set of data placed in a sequential manner

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

What are the different types of data structures in python ?

A

The types of data structures are:
1 Series - an 1 d array
2 data frame - a 2 d array

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

What are the features of series?

A
  1. 1 darray
  2. contain homogenous data type
  3. is mutable (size is not)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you create a empty series?

A

import pandas as pd
df = pd.Series()
______________

output:
Series([], dtype: object)

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

How to create a series using a list?

A

import pandas as pd
l=[1,2,3]
df = pd.Series(l)
______________
output:
0 1
1 2
3 3
dtype: int64

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

How to create a series using a dictionary?

A

import pandas as pd
d={‘A’:1,’B’:2}
df = pd.Series()
______________

output:
A 1
B 2

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

How to create an empty series with a tuple ?

A

import pandas as pd
t= 1,2,3
df = pd.Series()
______________
output:
0 1
1 2
3 3
dtype: int64

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

How to create a series using a scalar value

A

import pandas as pd
df = pd.Series(25,index=[1,2,3])
or
df = pd.Series(25, [1,2,3])
or df=pd.Series(25)
______________
output:
1 25
2 25
3 25
or
1 25
2 25
3 25
or
0 25

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

What is a scalar value ?

A

A scalar values can be defined as a constant value

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

How to specify a certain range of values as the index?

A

import pandas as pd
df = pd.Series(290, index= range(2020,2091))
print(df)

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

How to insert a Nan value in a series ?

A

import pandas as pd
import numpy as np
df= pd.Series([1,2,3,np.NaN,5,6])
print(df)

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

How does the dtype change as soon as we add a Nan value to it?

A

A soon as the Nan value is added the dtype changes to float64

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

What are attributes ?

A

Attributes are characteristic of the of the element

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

What are the different types of attributes used in Series?

A

The different type of attributes used are:
1. Shape it talks about the shape the data structure
value given in the form of a tuple
(n,) one is not shown here

2.Empty it is used to check if the given structure is empty or not
output is given in the form of boolean

  1. Values it is used just to print all the values in the structure only the values
    represented in the form of a list

4.Index it is used to print all the indexes used in the structure only indexes
in the form of a list

  1. Size it is used to check the total number of entries in the the Series
    in the the form of an int value

6.ndim it is used to check the dimension of the data structure
in the form of int

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

Some other attributes used in Series which may or may not work are

A

nbyte and itemsize it is used to find out the amount of space occupied by an given element.

17
Q

Operation on series are done using

A

It can either be done using the operator or using function such as sum() ,div() ,sub() ,mul()

18
Q

What does the letter ‘r’ represent in rsum() ,rdiv() ,rsub() ,rmul()

A

It reverses the order of operation or you can say that it solves from right hand side

19
Q

How can you slice through a list ?

A

Different way are used as per requirements,
1. if you want a single element
you use the normal method
print(df[index])

  1. if you want multiple elements
    print(df[1:4:2])