Haven't found a clear enough answer in the docs or other similar questions on stack overflow, so here it is. As the title says, provide some scenarios where loc or iloc should be used over the [] operator in pandas and explain why.
In what cases are loc and iloc a better approach than just using __getitem__ with pandas dataframes?
Asked
Active
Viewed 97 times
2
-
2this is a good example telling all the story detailed for me : https://stackoverflow.com/questions/31593201/how-are-iloc-ix-and-loc-different – canarcho Oct 04 '19 at 13:38
-
1Thanks @paito1 I had seen that post already and found it extremely useful. The last answer talks a little more about the indexing operator but I wasn't certain that that is the entire story. They just say that the indexing operator "cannot select rows and columns simultaneously". Others on the forum speak of "more complex selection" that is not possible with the [] operator, but unless they just mean simultaneous column and row selection then I don't know what those situations are. – michael_question_answerer Oct 04 '19 at 13:55
-
Yes it does, thank you Georgy. – michael_question_answerer Nov 10 '21 at 09:26