-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseries.py
More file actions
75 lines (61 loc) · 1.23 KB
/
series.py
File metadata and controls
75 lines (61 loc) · 1.23 KB
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
72
73
74
75
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 20 10:44:14 2021
@author: deepak
"""
import pandas as pd
obj=pd.Series([1, 24, 34, 35, 23, 3, 2, 55])
print(obj)
print(obj.values)
print(obj.index)
sdata={'ohio': 35000, 'texas': 71000, 'oregon': 16000, 'utah': 5000}
print(sdata)
obj3=pd.Series(sdata)
print(obj3)
print()
states=['california', 'ohio', 'oregon', 'texas']
obj4=pd.Series(sdata, index=states)
print(obj4)
print()
print('isnull: ')
print(pd.isnull(obj4))
print()
print(obj4.isnull())
print()
print(obj4.isnull().sum())
print()
print(pd.notnull(obj4))
print()
print(obj4.notnull())
print('Critical series features:-')
print()
print(obj3)
print()
print(obj4)
print()
o9=(obj3+obj4)
print(o9)
print('----------------------------------------------------------')
obj4.name='Population'
obj4.index.name='state'
print(obj4)
obj=pd.Series([4, 7, -5, 3])
obj.index=['bob', 'steve', 'jeff', 'rayan']
print(obj)
#numpy
import numpy as np
import math
obj=pd.Series([4, 7, -5, 3], index=['d', 'b', 'a', 'c'])
print(obj)
o1= (obj[obj>0])
print(o1)
o2=(obj*2)
print(o2)
o3=(np.exp(obj))
print(o3)
obj=pd.Series([1, 2, 3, 4, 5, 6], index=['a', 'b', 'c', 'd', 'e', 'f'])
print(obj)
print(obj.values)
print(obj.index)
print(obj['a'])