-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatascience_play.py
More file actions
31 lines (26 loc) · 934 Bytes
/
Copy pathdatascience_play.py
File metadata and controls
31 lines (26 loc) · 934 Bytes
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
print("Using Raw Python")
DATA = [
('Jones', 'Jane', 58),
('Smith', 'Anne', 30),
('Jones', 'Fred', 30),
('Smith', 'John', 60),
('Smith', 'Fred', 30),
('Jones', 'Anne', 30),
('Smith', 'Jane', 58),
('Smith', 'Twin2', 3),
('Jones', 'John', 60),
('Smith', 'Twin1', 3),
('Jones', 'Twin1', 3),
('Jones', 'Twin2', 3)
]
for tup in DATA:
print("{:10s} {:10s} {}".format(*tup))
print("Using Pandas and Numpy")
import numpy as np
import pandas as pd
data = pd.DataFrame([('Jones', 'Jane', 58), ('Smith', 'Anne', 30), ('Jones', 'Fred', 30),
('Smith', 'John', 60), ('Smith', 'Fred', 30), ('Jones', 'Anne', 30),
('Smith', 'Jane', 58), ('Smith', 'Twin2', 3), ('Jones', 'John', 60),
('Smith', 'Twin1', 3), ('Jones', 'Twin1', 3), ('Jones', 'Twin2', 3)],
index=[list(range(12))], columns= ["Last Name", "First Name", "Age"])
print(data)