DOC: Comparing .loc/.iloc to tuples and chained indexing #60632
Labels
Docs
Indexing
Related to indexing on series/frames, not to indexes themselves
Needs Discussion
Requires discussion from core team before further action
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#indexing-view-versus-copy
Documentation problem
For code such as the code shown above, the df may or may not be update Jason's age to 29 due to the chained indexing that is being used.
The documentation mentions how .iloc/.loc is a better option. For example, something such as the following.
df.loc[df['Name'] == 'Jason', 'Age'] = 29
However it is not clear about best practices regarding tuples, such as the following.
df[('Age', df['Name'] == 'Jason')] = 29
Suggested fix for documentation
The suggested fix is to explain how the use of tuples would compare to the use of .iloc/.loc and the use of chained indexing in the context of best practices in pandas. Considerations can include time complexity, space complexity, code readability, etc.
The text was updated successfully, but these errors were encountered: