TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' が出た




「TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'」
今まで動いていたロジックを動かしてみたら、上のようなエラー。

intにしようとしたけど、Noneあるで、っていう感じです。

ロジックをみた所、

df['data'] = df['data'].astype(int)

と、データが必ずint変換できる場合じゃないと動かない形になっていて、
しかもNoneが入ってくることを考慮していない。

df['data'] = df['data'].dropna().astype(int)

とNoneの行は落とす形にしてからastypeするようにして解決。