What is Pandas doing here that my indexes  and  refer to the same value?
I have a dataframe with these indices and values:
When I access df[df.columns], I get “example1”. Makes sense. That’s how indices work.
When I access df[df.columns], however, I get “example”, and I get example when I access df[df.columns] as well. So for
I get “example”.
Strangely, I can delete “row” 0, and the result is that 1 is deleted:
But when I delete row 1, then
is deleted, as opposed to example.
This is a bit confusing to me; are there inconsistent standards in Pandas regarding row indices, or am I missing something / made an error?
You are probably causing pandas to switch between
All arrays in Python are 0 indexed. And I notice that indexes in your DataFrame are starting from 1. So when you run
When you run
When you delete the first row, your DataFrame does not have index labels 0 and 1. So when you go to locate elements at those places in the way you are, it does not return
To enforce pandas to use one of the two indexing techniques, use
These commands are bad practice:
See Different Choices for Indexing for more information.