pandas .at versus .loc

后端 未结 4 1413
情歌与酒
情歌与酒 2020-11-27 15:20

I\'ve been exploring how to optimize my code and ran across pandas .at method. Per the documentation

Fast label-based scalar ac

4条回答
  •  生来不讨喜
    2020-11-27 16:16

    .at is an optimized data access method compared to .loc .

    .loc of a data frame selects all the elements located by indexed_rows and labeled_columns as given in its argument. Insetad, .at selects particular elemnt of a data frame positioned at the given indexed_row and labeled_column.

    Also, .at takes one row and one column as input argument, whereas .loc may take multiple rows and columns. Oputput using .at is a single element and using .loc maybe a Series or a DataFrame.

提交回复
热议问题