Can someone explain this behavior to me?
import pandas as pd dates = pd.date_range('1/1/2000', periods=8) df = pd.DataFrame(np.random.randn(8, 4), index=dates, columns=['A', 'B', 'C', 'D']) df.ix['2000-01-01':'2000-01-02', ['A', 'C']]
I expected both indexing operations to return the same (first) result.
Then I got it:
from datetime import datetime df.loc[[datetime(2000, 1, 1), datetime(2000, 1, 5)], ['A','C']] ## Output AC 2000-01-01 0.224944 -0.689382 2000-01-05 -0.393747 0.462126
Now I do not know the internal elements of pandas and why it implicitly converts strings to dates for a given range, but not for a given list, but I assume that the range makes it clear that we mean an object with an ordinal character, so pandas may check index, sees that this time already analyzes strings as dates.
But then the question arises, why does it do the right thing when we deliver one line?
df.loc['2000-01-01', ['A','C']] ## Output: A 0.224944 C -0.689382 Name: 2000-01-01 00:00:00, dtype: float64
Is this a performance issue when trying to convert multiple values ββwhile providing a list? Some other design decisions?