Pandas Flashcards
What is Pandas?
It is module/ function of python that is used to store data in the form of dataframe fore easy operations
Data Structure ?
It is an organized set of data placed in a sequential manner
What are the different types of data structures in python ?
The types of data structures are:
1 Series - an 1 d array
2 data frame - a 2 d array
What are the features of series?
- 1 darray
- contain homogenous data type
- is mutable (size is not)
How can you create a empty series?
import pandas as pd
df = pd.Series()
______________
output:
Series([], dtype: object)
How to create a series using a list?
import pandas as pd
l=[1,2,3]
df = pd.Series(l)
______________
output:
0 1
1 2
3 3
dtype: int64
How to create a series using a dictionary?
import pandas as pd
d={‘A’:1,’B’:2}
df = pd.Series()
______________
output:
A 1
B 2
How to create an empty series with a tuple ?
import pandas as pd
t= 1,2,3
df = pd.Series()
______________
output:
0 1
1 2
3 3
dtype: int64
How to create a series using a scalar value
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
What is a scalar value ?
A scalar values can be defined as a constant value
How to specify a certain range of values as the index?
import pandas as pd
df = pd.Series(290, index= range(2020,2091))
print(df)
How to insert a Nan value in a series ?
import pandas as pd
import numpy as np
df= pd.Series([1,2,3,np.NaN,5,6])
print(df)
How does the dtype change as soon as we add a Nan value to it?
A soon as the Nan value is added the dtype changes to float64
What are attributes ?
Attributes are characteristic of the of the element
What are the different types of attributes used in Series?
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
- 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
- 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