Understanding inplace=True

后端 未结 11 1289
遥遥无期
遥遥无期 2020-11-22 03:25

In the pandas library many times there is an option to change the object inplace such as with the following statement...

df.dropna(axis=\'index\         


        
11条回答
  •  独厮守ぢ
    2020-11-22 03:34

    When inplace=True is passed, the data is renamed in place (it returns nothing), so you'd use:

    df.an_operation(inplace=True)
    

    When inplace=False is passed (this is the default value, so isn't necessary), performs the operation and returns a copy of the object, so you'd use:

    df = df.an_operation(inplace=False) 
    

提交回复
热议问题