Pandas Basic tutorial 1 - Python Programming |
Open
Anaconda Navigator
Launch
Sypder
PROGRAM
1
import pandas as pd
ser = pd.Series()
print (ser)
OUTPUT
Series([], dtype: float64)
PROGRAM
2
import pandas as pd
import numpy as np
names = np.array(['somi','suzi','sakha','sumi'])
age=np.array(['20','21','26','25'])
ser1 = pd.Series(names)
ser2 = pd.Series(age)
print (ser1)
print(ser2)
OUTPUT
0 somi
1 suzi
2 sakha
3 sumi
dtype: object
0 20
1 21
2 26
3 25
dtype: object
PROGRAM
3
import pandas as pd
import numpy as np
names = np.array(['somi','suzi','sakha','sumi'])
ser1 = pd.Series(names, index=[10,11,12,13])
print (ser1)
OUTPUT
10 somi
11 suzi
12 sakha
13 sumi
dtype: object
PROGRAM
4
import pandas as pd
names ={'somi':1,'suzi':2,'sakha':3,'sumi':4}
ser1 = pd.Series(names, index=['somi','suzi','sakha','sumi'])
ser2 = pd.Series(names, index=[1,2,3,4])
print (ser1)
print(ser2)
OUTPUT
somi 1
suzi 2
sakha 3
sumi 4
dtype: int64
1 NaN
2 NaN
3 NaN
4 NaN
dtype: float64
PROGRAM
5
import pandas as pd
ser = pd.Series([1,2,3,4,5,6,7],index = ['a','b','c','d','e','f','g'])
print('ser[0]')
print (ser[0])
print('ser[4]')
print(ser[4])
print('ser[:]')
print(ser[:])
print('ser[1:]')
print(ser[1:])
print('ser[:4]')
print(ser[:4])
print('ser[-3:]')
print (ser[-3:])
print('ser[c]')
print (ser['c'])
print('ser[e]')
print (ser['e'])
print('ser['e','a','b']')
print (ser[['e','a','b']])
OUTPUT
ser[0]
1
ser[4]
5
ser[:]
a 1
b 2
c 3
d 4
e 5
f 6
g 7
dtype: int64
ser[1:]
b 2
c 3
d 4
e 5
f 6
g 7
dtype: int64
ser[:4]
a 1
b 2
c 3
d 4
dtype: int64
ser[-3:]
e 5
f 6
g 7
dtype: int64
ser[c]
3
ser[e]
5
ser[e,a,b]
e 5
a 1
b 2
dtype: int64
Pandas
Basic tutorial 2 - Python Programming CLICK HERE
Pandas
Basic tutorial 3 - Python Programming CLICK HERE
Pandas
Basic tutorial 4 - Python Programming CLICK HERE