Search code examples
pythonpandasdataframerow

Deleting rows with removed comments from dataframe using Pandas


I am trying to do some data cleaning. I have removed the rows with "nan" using pandas dropna, but I still don't know how to drop all the rows with "[removed]" (This picture shows the head of my dataset). Any help would be greatly appreciated! thank you in advance :)

picture


Solution

  • You can use boolean-indexing:

    mask = df.Body.eq("[removed]")
    df = df[~mask]
    print(df)