-
Notifications
You must be signed in to change notification settings - Fork 2
/
series.py
71 lines (51 loc) · 1.48 KB
/
series.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import pandas as pd
import numpy as np
#blank series
s = pd.Series()
print(s)
#series with numbers
s = pd.Series([10,20,30,40,50])
print(s)
#series with numbers and index
s= pd.Series([10,20,30,40,50],index=[1,2,3,4,5])
print(s)
#series with numbers and char index
s = pd.Series([10,20,30,40,50],index=['a','b','c','d','e'])
print(s)
#series with constant values
s = pd.Series(55,index=[1,2,3,4,5,6])
print(s)
#series with constant and python function
s = pd.Series(34,index= range(100))
print(s)
# series with python function
s = pd.Series(range(2,89))
print(s)
# series with float values
s = pd.Series([10,20,30,40.5,50])
print(s)
# series with string type values
s = pd.Series('Welcome to DAV Chander Nagar',index=[1,2,3,4,5,6])
print(s)
# series with string and index also in string
s= pd.Series('Welcome to DAV Chander Nagar',index=['rakesh','arushi','mannat','vinay','pratham'])
print(s)
# series with range and for loop
s = pd.Series(range(5),index = [x for x in 'abcde'])
print(s)
# series with two different lists
names =['rakesh','vishank','nikunj','unnati','vipul']
city = [ 'GZB','Delhi','Meerut','Pune','Panji' ]
s = pd.Series(names,index=city)
print(s)
#series with Nan values of numpy
s = pd.Series([10,20,30,np.NaN,-34.5,6])
print(s)
#series from a python Dictionary
dict1={'name':'rakesh','roll':20,'city':'Gzb','age':40,'profession':'Teaching'}
s= pd.Series(dict1)
print(s)
# series using a mathematical expression
data =np.arange(10,15)
s= pd.Series(data**2,index= data)
print(s)