class circle:
def __init__(self): #init前後都兩個下底線
self.radius=1
“””
每次用circle()建立一個物件時
就會自動執行__init__
該物件建立一個radius變數
其值為1
“””
my_cir = circle()
print(2*3.14* my_cir.radius )
#my_cir.radius預設值=1
my_cir.radius=5
print(2*3.14* my_cir.radius )


class circle:
def __init__(self,rad): #rad是函數參數
self.radius= rad #self.radius物件變數
def area(self):
return self.radius*self.radius*3.14
my_cir = circle(1)
print(my_cir) #印出物件而已
print(my_cir.area()) #還要物件.method


![Python: pandas.DataFrame 如何找出重複值並計算重複次數? counts = df[duplicates] .groupby([‘name’]) .size() .reset_index(name=’count’) Python: pandas.DataFrame 如何找出重複值並計算重複次數? counts = df[duplicates] .groupby([‘name’]) .size() .reset_index(name=’count’)](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230316131103_65.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



![Python, typing: 函數庫規格標註; def addTest(x:float, y:float) -> float: List[資料型態] Set[資料型態] Tuple[資料型態] Dict[str,value的資料型態] Union[資料型態1, 資料型態2] ,函式若有多個輸出值,其實是輸出一個tuple Python, typing: 函數庫規格標註; def addTest(x:float, y:float) -> float: List[資料型態] Set[資料型態] Tuple[資料型態] Dict[str,value的資料型態] Union[資料型態1, 資料型態2] ,函式若有多個輸出值,其實是輸出一個tuple](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2022/09/20220907154601_86.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python: 如何用numpy.ndarray的reshape 將3D array轉為2D array,再轉為pandas.DataFrame? arr.reshape( arr.shape[0] * arr.shape[1] , -1) Python: 如何用numpy.ndarray的reshape 將3D array轉為2D array,再轉為pandas.DataFrame? arr.reshape( arr.shape[0] * arr.shape[1] , -1)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230320082325_85.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Python: pandas.DataFrame的串接 pandas.concat() #concatenate 連接, 如何重新排列columns 順序? df[[“甲”, “乙”, “丙”]] ; df.reindex( columns = [“甲”, “乙”, “丙”] ) Python: pandas.DataFrame的串接 pandas.concat() #concatenate 連接, 如何重新排列columns 順序? df[[“甲”, “乙”, “丙”]] ; df.reindex( columns = [“甲”, “乙”, “丙”] )](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2023/05/20241120092030_0_98dff3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言