여기는 기본적인 파이썬 함수들을 정리합니다.

 

1. 객체의 삭제 : del 객체명 

위와 같이 하면, 정리가 됩니다.

 2. 다중 조건문을 사용해서 변수를 사용하는 방법 

 

 A. numpy.select를 사용하는 방법

col = 'consumption_energy'

conditions = [ df2[col] >= 400, (df2[col] < 400) & (df2[col]> 200), df2[col] <= 200 ]

choices = [ "high", 'medium', 'low' ]

 

df2["energy_class"] = np.select(conditions, choices, default=np.nan)

 

 B. numpy.where를 중첩해서 사용하는 방법

 

 C. 사용자 함수를 만들어서 넣는 방법

반응형

+ Recent posts