Python Pandas:“ loc”和“ iloc”代表什么吗?

Boo*_*d16 9 python pandas

我一直在使用熊猫有一段时间了,我明白了什么lociloc做。但是直到今天,我都不知道这两件事是否代表某种意义?他们是某种缩写还是缩写?还是只是随机的?

我将其解释iloc为“基于索引的位置”,这很有意义,但loc对我来说有点问题,我将其解释为“位置”,但没有喊出“基于标签的位置”,为什么他们不能称之为“基于标签的位置” lloc

Jab*_*Jab 7

To properly answer your question, as you are asking "Does loc and iloc stand for anything?" and not What is the difference between loc and iloc?.

I've done some research, and found from this github issue which lead me to this summary. And from these docs, I believe this sums up with these statements

Different Choices for Indexing

Object selection has had a number of user-requested additions in order to support more explicit location based indexing.

  • .loc: is primarily label based
  • .iloc: is primarily integer position based

And on the chance we want to include ix

  • .ix supports mixed integer and label based access. It is primarily label based, but will fall back to integer positional access continue

Selection By Label

pandas provides a suite of methods in order to have purely label based indexing... - continued

  • The .loc attribute is the primary access method. ?

Selection By Position

pandas provides a suite of methods in order to get purely integer based indexing... - continued

  • The .iloc attribute is the primary access method. ?

This does also apply to .at and .iat as well.

Similarly to loc, at provides label based scalar lookups, while, iat provides integer based lookups analogously to iloc


To sum up

I personally like how I said it in my comment but I will elaborate

It doesn't seem like there is a concrete correlating abreviation symantically or in the docs; other than it really just lamens "location" vs "integer location". Human Readable Labels vs Computer Logical Indexing. It happens for everyone, especially with new or complicated languages or ideoligies; where you know what something does and how to use it, but it's unsettling when you try to rationalize it's meaning or sort of explain or talk yourself through it.

Seems that's a Pythonista's nightmare and dream all in one. - (Me)

顺便说一句,我撤回了我的近距离投票,并给了你赞成票,因为那确实需要一些勇气来对已经被问到的话题进行更多的澄清,但是我也知道我在学习时也遇到了问题。希望这可以帮助

  • 仅最后一部分(“总结”下)相关,其余部分讨论loc / iloc再次执行的操作。您可能要考虑删除那些部分,以使您的答案更清晰。 (2认同)
  • 我喜欢这个。“位置”与“整数位置”。人类可读标签与计算机逻辑索引。 (2认同)