Search code examples
pythondataframecsvmissing-data

Empty cell in csv not detected in python


I'm already using .isna and .isnull to check for missing value in my data and it shows that there is no missing value in the data. But when I skimming the data using excel, I found several empty cells in a column. That column was supposed to have numerical data type, but it got identified as object because it has several empty cells. If I want to delete these cells, what should I do?


Solution

  • That column was supposed to have numerical data type, but it got identified as object because it has several empty cells.

    This suggest that they are empty strings, ''. You could replace them with NaN values using replace:

    df = df.replace('', np.nan)