1 (1)
1 (1)
•Pandas has derived its name from “Panel data system”, (term
used for structured data sets.
•It can calculate in all ways data is organised i.e across rows
and columns.
•It can easly select subsets of data from bulky data sets and
even combine multiple datasets together.
•Scalar value
5/05/20
• eg
import pandas as pd
import numpy as np
a=np.arange(9,13)
print (a)
[ 9 10 11 12]
S=pd.Series(index=a,data=a*2)
S
Out[6]:
9 18
10 20
11 22
12 24
dtype: int32
6/05/20
SERIES ATTRIBUTES
• indexes separately
•Filtering Entries
1. Modifying Elements of Series Object
The data values of a Series object can be easily
modified through item assignment
•Filtering Entries
The head() and tail() functions
s=pd.Series([2,3,21,12,31,7,8])
s
Out[3]:
0 2
1 3
2 21
3 12
4 31
5 7
6 8
dtype: int64
s
Out[7]:
0 2
1 3
2 21
3 12
4 31
5 7
6 8
dtype: int64
s.head(4)
Out[8]:
0 2
1 3
2 21
3 12
dtype: int64
import pandas as pd
s=pd.Series([2,3,21,12,31,7,8])
s
Out[3]:
0 2
1 3
2 21
3 12
4 31
5 7
6 8
dtype: int64
s.tail(3)
Out[9]:
4 31
5 7
6 8
dtype: int64
VECTOR OPERATIONS ON SERIES OBJECTS
import pandas as pd
s+2 s*3
s=pd.Series([2,3,21,1 Out[10]: Out[11]:
2,31,7,8]) 0 4 0 6
1 5 1 9
s 2 23 2 63
Out[3]: 3 14 3 36
0 2 4 33 4 93
1 3 5 9 5 21
2 21 6 10 6 24
3 12 dtype: int64
4 31
5 7
6 8
dtype: int64
import pandas as pd
s=pd.Series([2,3,21,1
2,31,7,8])
s s=s**2
Out[3]: Out[16]:
0 2 0 4
1 3 1 9
2 21 2 441
3 12 3 144
4 31 4 961
5 7 5 49
6 8 6 64
dtype: int64 dtype: int64
Filtering Entries
import pandas as pd
s=pd.Series([2,3,4,1])
s2=pd.Series([6,7,8,9])
s+s2
Out[25]:
0 8
1 10
2 12
3 10
dtype: int64
11/05/20
•Filtering Entries
The head() and tail() functions
s=pd.Series([2,3,21,12,31,7,8])
s
Out[3]:
0 2
1 3
2 21
3 12
4 31
5 7
6 8
dtype: int64
s
Out[7]:
0 2
1 3
2 21
3 12
4 31
5 7
6 8
dtype: int64
s.head(4)
Out[8]:
0 2
1 3
2 21
3 12
dtype: int64
import pandas as pd
s=pd.Series([2,3,21,12,31,7,8])
s
Out[3]:
0 2
1 3
2 21
3 12
4 31
5 7
6 8
dtype: int64
s.tail(3)
Out[9]:
4 31
5 7
6 8
dtype: int64
VECTOR OPERATIONS ON SERIES OBJECTS
import pandas as pd
s+2 s*3
s=pd.Series([2,3,21,1 Out[10]: Out[11]:
2,31,7,8]) 0 4 0 6
1 5 1 9
s 2 23 2 63
Out[3]: 3 14 3 36
0 2 4 33 4 93
1 3 5 9 5 21
2 21 6 10 6 24
3 12 dtype: int64
4 31
5 7
6 8
dtype: int64
import pandas as pd
s=pd.Series([2,3,21,1
2,31,7,8])
s s=s**2
Out[3]: Out[16]:
0 2 0 4
1 3 1 9
2 21 2 441
3 12 3 144
4 31 4 961
5 7 5 49
6 8 6 64
dtype: int64 dtype: int64
Filtering Entries
import pandas as pd
s=pd.Series([2,3,4,1])
s2=pd.Series([6,7,8,9])
s+s2
Out[25]:
0 8
1 10
2 12
3 10
dtype: int64
12/05/20