데이터 분석/[Python] Troubleshooting

OverflowError: Python int too large to convert to C long

INCHELIN 2021. 9. 9. 17:53
728x90

astype(int)를 했을 때, 다음과 같은 오류를 만나는 경우가 있습니다

OverflowError: Python int too large to convert to C long

 

import sys
sys.maxsize

숫자가 sys.maxsize보다 크면 해당 오류가 발생할 수 있는데,

쉽게 pd.to_numeric( )으로 하면 해결될 수 있습니다.

df['가격'] = df['가격'].astype(int) # OverflowError
df['가격'] = pd.to_numeric(df['가격'])
728x90