Pandas iloc, ix, and loc explained

This post introduces the differences among iloc, ix, and loc.

Note: in pandas version > = 0.20.0, ix is deprecated . Thus, useloc and iloc instead.

  • loc — gets rows (or columns) with particular labels from the index.
  • iloc — gets rows (or columns) at particular positions in the index (so it only takes integers).
  • ix — usually behaves like loc but falls back to behaving like iloc if a label is not present in the index.


pandas iloc vs ix vs loc explanation? (pdf)