0

I want to convert my entire column to int.

I need this to work:

df = df[(df.col > 0)  | (df.col < 10)]

So I tried it and it says:

TypeError: '<' not supported between instances of 'str' and 'int'

So I tried this:

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

But I got this:

ValueError: invalid literal for int() with base 10: '-1e+31'

Then I tried this based on an answer:

df['col'] = int(float(df['col']))

And it says:

TypeError: cannot convert the series to <class 'float'>

How can I make it work? Many thanks.

Ariadne R.
  • 452
  • 11
  • 24

0 Answers0