pandas loc vs. iloc vs. ix vs. at vs. iat? [英] pandas loc vs. iloc vs. ix vs. at vs. iat?

查看:101
本文介绍了pandas loc vs. iloc vs. ix vs. at vs. iat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近开始从我的安全位置(R)分支到Python,并且对Pandas中的单元格定位/选择有些困惑.我已经阅读了文档,但仍在努力了解各种本地化/选择选项的实际含义.

Recently began branching out from my safe place (R) into Python and and am a bit confused by the cell localization/selection in Pandas. I've read the documentation but I'm struggling to understand the practical implications of the various localization/selection options.

  • 有没有理由我应该在最普通的选项.ix上使用.loc.iloc?
  • 我了解到.locilocatiat可能提供了.ix无法提供的某些保证的正确性,但我也阅读了.ix往往是全面最快的解决方案.
  • 请解释使用除.ix以外的任何东西的真实世界的最佳实践推理吗?
  • Is there a reason why I should ever use .loc or .iloc over the most general option .ix?
  • I understand that .loc, iloc, at, and iat may provide some guaranteed correctness that .ix can't offer, but I've also read where .ix tends to be the fastest solution across the board.
  • Please explain the real-world, best-practices reasoning behind utilizing anything other than .ix?

推荐答案

loc:仅适用于索引
iloc:在位置上进行工作
ix:您可以从数据框中获取数据,而不必将其包含在索引中
at :获取标量值.这是一个非常快速的位置
iat :获取标量值.这是一个非常快的iloc

loc: only work on index
iloc: work on position
ix: You can get data from dataframe without it being in the index
at: get scalar values. It's a very fast loc
iat: Get scalar values. It's a very fast iloc

http://pyciencia. blogspot.com/2015/05/obtener-y-filtrar-datos-de-un-dataframe.html

注意:从pandas 0.20.0开始,.ix索引器为

Note: As of pandas 0.20.0, the .ix indexer is deprecated in favour of the more strict .iloc and .loc indexers.

这篇关于pandas loc vs. iloc vs. ix vs. at vs. iat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆