Search code examples
pythonpandasnumpycsvexport-to-csv

How to remove NaN on CSV?


I have a .csv file of a table consisting of 12 col and 30k rows. One of the col is 'mentions', some of the data are empty (NaN). I am trying to remove all the rows where mentions = NaN. I don't want to fill it with new data. I just wanna remove those rows so they wont be part of the analysis.

Please help. Thank you.

I will be saving the csv file after as another file to conduct a network analysis via networkx


Solution

  • Assuming your DataFrame is named df:

    df = df.dropna(subset=["mentions"])