Can't drop NAN with dropna in pandas

后端 未结 4 1918
心在旅途
心在旅途 2020-11-27 07:54

I import pandas as pd and run the code below and get the following result

Code:

traindataset = pd.read_csv(\'/Users/train.csv\')
print traindataset.d         


        
4条回答
  •  情话喂你
    2020-11-27 08:24

    You need to read the documentation (emphasis added):

    Return object with labels on given axis omitted

    dropna returns a new DataFrame. If you want it to modify the existing DataFrame, all you have to do is read further in the documentation:

    inplace : boolean, default False

    If True, do operation inplace and return None.

    So to modify it in place, do traindataset.dropna(how='any', inplace=True).

提交回复
热议问题