오류 코드
typeerror: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
해결 방법
# 기존 코드
def create_chart(self, dataframe):
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111)
mpl_finance.candlestick2_ohlc( ~~~~~ )
# 변경 코드
def create_chart(self, dataframe):
data = dataframe.astype(float)
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111)
mpl_finance.candlestick2_ohlc( ~~~~~ )
부연 설명
본 오류는 mpl_finance를 통해 캔들 차트를 구현하고자 하는 과정에서 발생한 오류다. 오류가 발생했던 이유는 사용하고자 하는 데이터의 형태가 float32가 아니었기 때문이다.
따라서 '# 변경 코드'의 두 번째 줄에 있는 data = dataframe.astype(float)을 추가해주고, data를 기준으로 데이터를 설정하면 올바르게 생성되는 것을 확인할 수 있다.