Search code examples
pandascsvdatasetpredictionmissing-data

Stack with an error when trying to replace missing data


Please I need your help in my mini-project, I need to create a prediction model using a dataset from Kaggle, I am stuck with an error when I try to replace the missing data from a 'value' column. It seems that the value are considered like a string, because they have points between numbers. It's not possible to edit the column manually, it has more than 49000 rows. How can resolve this problem?
Here's the code and the error:

x['value'].replace(' ',np.NaN).astype(np.float)

ValueError: could not convert string to float: '154.619.063'

The dataset: Multinationals by industrial sector the dataset from Kaggle Thank you so much for your help


Solution

  • Try this:

    x['value'].str.replace('.', '').replace(' ', np.NaN).astype(np.float)