-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhellloworld.py
More file actions
48 lines (32 loc) · 1.26 KB
/
Copy pathhellloworld.py
File metadata and controls
48 lines (32 loc) · 1.26 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
import pandas as pd
import numpy as np
df = pd.DataFrame(np.arange(0, 20).reshape(5, 4))
# print(df)
# print(df[0])
# print(df[1][0])
# print(df[3])
arr = np.array([[1, 2],
[3, 4]])
arr[0][1] # -> 2 (row 0, col 1)
arr[0, 1] # -> 2
# print(df[0][1] ) # -> 3 (column label 0, then row label 1)
# print(df.iloc[0, 1]) # -> 2 (row 0, col 1 by position)
df[0][1] != df.iloc[0, 1] # True
df = pd.read_csv('data.csv', header=0, skipinitialspace=True) # first row -> column names
# print(df)
# print(df.iloc[1, 2]) # -> 7
# print(df[2][1]) # -> 7
# print(df.loc[1, 2]) # -> 7
# print(df["COL4"])
import matplotlib.pyplot as plt
# plt.plot([1, 2, 3, 4], [1, 4, 9, 16], color = 'blue', marker='o', linestyle='dashed') # 'ro' means red color, round points
# plt.xlabel('x axis')
# plt.ylabel('y axis')
# plt.title('My first graph')
# plt.savefig('plot.png', bbox_inches='tight') # save to workspace
# plt.show()
# plt.plot(df["COL1"], df["COL2"], color = 'blue', marker='o', linestyle='dashed') # 'ro' means red color, round points
# plt.scatter(df["COL1"], df["COL2"], color = 'blue')
plt.subplot(2, 1, 1,) # 'ro' means red color, round points
plt.savefig('plot.png', bbox_inches='tight') # save to workspace
plt.show()