4 ms·
I will agree about [] being overloaded, but .loc and .iloc are distinct for a good reason. .loc is for operations according to the index, .iloc is for operation
by _dain_ 5y ago
I will agree about [] being overloaded, but .loc and .iloc are distinct for a good reason. .loc is for operations according to the index, .iloc is for operations according to position. You have to reset_index() so often probably because you are not using the index properly. Effective use of Pandas means effective use and consideration of the indexes on your dataframes and series.
Recommended watching (32:00 onwards): https://www.youtube.com/watch?v=mWtfZaT7iSc https://www.youtube.com/watch?v=mWtfZaT7iSc