0

Here's my dataset

id   value
1      100
2       50

But the value is object not integer or float

In[3]:
device_age.dtypes
Out[3]
device_id    object
value        object
dtype: object

I want to make it integer int, here's what I try:

import numpy as np
device_age['value'] = device_age['value'].astype(np.int64)

and I also try

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

The error message is

invalid literal for int() with base 10: 'null'

Nabih Bawazir
  • 6,381
  • 7
  • 37
  • 70
  • Your dataframe contains null values. Can you please post the output of `device_age` in your iPython? – Mazdak May 16 '18 at 07:00
  • Possible duplicated https://stackoverflow.com/questions/21287624/convert-pandas-column-containing-nans-to-dtype-int?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Mazdak May 16 '18 at 07:03
  • I'm already using `df[df['value'] != 'null']` so it not contain null value anymore? – Nabih Bawazir May 16 '18 at 07:03
  • You are comparing with a `string` – Joe May 16 '18 at 07:04

0 Answers0