import numpy as np import pandas as pd dframe = pd.DataFrame(np.random.randn(8,4), columns=['A','B','C','D']) dframe dframe = pd.DataFrame(np.random.randn(8,4), columns=['A','B','C','D'], index = list('abcdefgh')) dframe dfdict = pd.DataFrame({'A':[1,2,3,4],'B': [5,6,7,8]},index = ['one','two','three','four']) dfdict dframe[0:4] dframe.iloc[0:4,0:2] The .loc method provides a way to use the labels of the dataframe effectively. It accepts integers as arguments but these are strictly related to the labels, not the position of a row/column. dframe.loc[list('bca'),['A','B']] dframe[dframe['C']>0] dframe[(dframe['C']>0) & (dframe['D']<0)] dframe['A'] = dframe['A'].map(lambda x: x+1) dframe gb = dframe.groupby(dframe['A']>0) gb.size() gb.sum() gb.median() gb.groups def square(x): return pd.Series([x, x**2]) dframe['A'].apply(square)