import pandas as pd
data=pd. Series(資料列表)
印出dtype屬性
print(data.dtype)
import pandas as pd
data=pd. Series (資料列表)
印出sizee屬性
print(data.size)
import pandas as pd
data=pd. Series(資料列表, index=索引列表)
印出index屬性
print(data.index)
import pandas as pd
data=pd.Series(資料列表)
取得資料data[順序]
print(data[1])
順序從0開始 所以1代表是第二個資料
import pandas as pd
data=pd.Series(資料列表, index=索引列表)
取得資料data[索引]
print(data[索引])
import pandas as pd
data=pd.Series([3,10,20,5,-12])
(各種數學、統計運算)
print(data.sum(,data.max(),data.prod())
prod是算出乘法的總和,全部相乘
print(data.mean(), data.median(),data.std())
mean是算出平均數
median是中位數
std是標準差
print(data.nlargest(3),data.nsmallest(2))
nlargest取(前3大)的數字
nsmallest 取最小的(2)個數字
import pandas as pd
data=pd.Series(["您好","Python","Pandas"])
各種字串操作,都定義在str底下
print(data.str.lower(),data.str.upper(),data.str.len())
(lower 把所有字串變小寫upper把所有字串變大寫len得到每一個字串長度)
print(data.str.cat(sep=","),data.str.contains("P"))
sep把字串串再一起,用(逗號)
contains 判斷字串中是否有(大寫P)
print(data.str.replace("您好","Hello"))
replace字串取代,把您好取代成Hello