I know the common methods to accesss index / columns in a Pandas dataframe (see also indexing guide):
df.iloc[..., ...]for integer locationdf.loc[..., ...]for label-based locationdf.ix(deprecated)df['C1']ordf.C1for column accessdf['mylabel1':'mylabel10']ordf[2:7]for row slice access, butdf['mylabel1']anddf[2]obviously don't work
I have always found the two last bullet points confusing, since we use the same notation df[...] for both column access or row access.
Question: is there a way to configure Pandas (or a subclass of DataFrame) that simplifies everything such that:
df[...] is in fact an alias for df.loc[...]
?
Example:
import numpy as np
import pandas as pd
x = pd.DataFrame(columns=['C1', 'C1', 'C2'])
x.loc['a'] = [np.random.rand(2000, 500), np.random.rand(2000, 500), np.random.rand(2000)]
print(x.loc['a', 'C2'])
x['a', 'C2'] # should give the same thing, so that by default, x[...] is the same as x.loc[...]