Skip to content

Instantly share code, notes, and snippets.

@Celia-code
Celia-code / matplotlib1.py
Last active March 11, 2020 07:50
This is for matplotlib
import matplotlib.pyplot as plt
x = [1, 3, 5, 7, 9]
y = [2, 4, 6, 8, 10]
plt.plot(x, y)
plt.show()
@Celia-code
Celia-code / matplotlib2.py
Created March 11, 2020 08:19
This is for matplotlib
import matplotlib.pyplot as plt
x = [1, 3, 5, 7, 9]
y = [2, 4, 6, 8, 10]
plt.plot(x, y, "-o-")
plt.show()
@Celia-code
Celia-code / pd1.py
Created March 11, 2020 09:18
This is for pandas
#建立Series
data = pd.Series([10, 15, 20])
print(data)
#打印出
"""
0 10
1 15
2 20
@Celia-code
Celia-code / pd2
Created March 11, 2020 09:23
This is for pandas
#建立Series
data = pd.Series([10, 15, 20])
print("最大值", data.max())
print("中位數", data.median())
#打印出
"""
最大值 20
@Celia-code
Celia-code / pd3.py
Created March 11, 2020 09:30
This is gor pandas
import pandas as pd
#建立dataframe
data = pd.DataFrame({
"name":["Amy", "Bob", "Chole"],
"score":[100, 80, 69]
})
print(data)
@Celia-code
Celia-code / pd4.py
Created March 11, 2020 09:35
This is for pandas
import pandas as pd
#觀察資料
data = pd.DataFrame({
"name":["Amy", "Bob", "Chole"],
"score":[100, 80, 69]
})
print("資料數量:", data.size)
print("資料型態(列, 欄):", data.shape)
print("資料索引:", data.index)
@Celia-code
Celia-code / pd6.py
Created March 11, 2020 09:51
This is for pandas
import pandas as pd
#
data = pd.DataFrame({
"name":["Amy", "Bob", "Chole"],
"score":[100, 80, 69]
})
#1.計算三位學生的成績平均值
score = data["score"]
@Celia-code
Celia-code / pd5.py
Created March 11, 2020 09:53
This is for pandas
import pandas as pd
data = pd.DataFrame({
"name":["Amy", "Bob", "Chole"],
"score":[100, 80, 69]
})
#取得row的Series資料
print("取得第二列:", data.iloc[1], sep = "\n")
#取得column的Series資料
@Celia-code
Celia-code / se1
Last active March 17, 2020 06:52
this is for selenium
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com/")
@Celia-code
Celia-code / se2
Last active March 17, 2020 08:01
this is for selenium
import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com/")
driver.find_element_by_name('q').send_keys('selenium')#至搜索框輸入selenium
time.sleep(1)
driver.find_element_by_class_name('tfB0Bf').find_element_by_tag_name('input').click() #點擊搜索框
driver.close()