饿,TIM老师的这个方程其实是可以化简的,也不是很复杂
import pandas as pd import numpy as np # def get_circumcircle_area(l,h): # r = np.sqrt(l**2+h**2)/2 # return r**2*np.pi # def get_circumcircle_area(l,h): # return np.pi*(l**2+h**2)/4 # # def wrapper(row): # return get_circumcircle_area(row['Length'],row['Height']) rects = pd.read_excel('D:/Temp/Rectangles.xlsx',index_col='ID') rects['CA'] = rects.apply(lambda row:np.pi*(row['Length']**2+row['Height']**2)/4,axis=1) print(rects)
这样的话一行就可以了