I have a DataFrame
pandas and I want to access a specific row and columns, and specifically I want to index the row by position and the column by label. Right now I'm doing it by chaining one call to .iloc
and one call to .loc
, but I'm wondering if there's a more efficient way:
d1 = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=["a", "b", "c"])
d1.iloc[-1].loc[:"b"] # Mi método actual
Neither .ix
, nor .loc
nor .iloc
allow me to do it in a single call by indexing rows and columns (I get KeyError
or TypeError
). Am I mistaking something fundamental?