Search code examples
pythondata-cleaningrowdeleting

how to delete for an empty row in a column in python csv


I will like to delete all empty row in a column

prices_dataframe[prices_dataframe['postcode'].isnull()]

This only seems to be showing me the empty rows not deleting it.


Solution

  • Is Null only returns the empty rows it does not drop them. Your empty rows should contain NaN so you can use `prices_dataframe.dropna(inplace=True) To drop them.

    If your rows don't contain NaN you can first replace the empty rows with NaN prices_dataframe.replace('', np.nan, inplace=True) and then drop them