obj.get(key) -- returns an item from an object (e.g. a column from a DataFrame, a value from a Series, etc.)
df[col] -- select and name a column and return it as a Series
df.loc[label1, label2, ...] -- select one or more rows or columns in a DataFrame by its label
df.loc[row_label, col_label] -- select a single item in a DataFrame by its row and column labels
df.loc[start_row_label : end_row_label, start_col_label : end_col_label] -- select a slice of a DataFrame by starting and ending row/column labels
df.iloc[row_index,:] -- select a row in a DataFrame by index position
df.iloc[row_index, col_index] -- select a single item in a DataFrame by the index position of its row and col
df.iloc[start_index : end_index, start_index : end_index] -- select a slice of a DataFrame by starting and ending index row/column positions; (ending index stop at index before it)
s.iloc[index] -- select a single item by its position
s.loc[index] -- select a slice of items from a Series
df[[col1, col2]] -- select and name multiple columns and return them as a new data frame
df.nlargest(n, 'value') -- Select and order top n entries.
df.nsmallest(n, 'value') -- Select and order bottom n entries
obj.truncate([before, after, axis) -- Truncate an object before and after some index value (*S & df)
obj.where(cond, other = NaN, inplace = False, axis = None) -- replace values in the object where the condition is False
df1.append(df2) -- add the rows in df1 to the end of df2 (columns should be identical)
df.concat([df1, df2],axis=1) —- add the columns in df1 to the end of df2 (rows should be identical)
df1.join(df2,on=col1,how='inner') —- SQL-style join the columns in df1 with the columns on df2 where the rows for colhave identical values. how can be equal to one of: 'left', 'right', 'outer', 'inner'
df.sort_values(col1) -- sort values in a certain column in ascending order
df.sort_values(col2,ascending=False) -- sort values in a certain column in descending order
df.sort_values([col1,col2],ascending=[True,False]) -- sort values in a col1 in asscending order, then sort values in col2 in descending order
df[df[col] > 0.5] # Rows where the col column is greater than 0.5
df[(df[col] > 0.5) & (df[col] < 0.7)] # Rows where 0.5 < col < 0.7
df.groupby(col) -- returns groupby object for values from a single, specific column
df.groupby([col1,col2]) -- returns a groupby object for values from multiple columns, which you can specify
df.groupby(col1)[col2].mean() # Returns the mean of the values in col2, grouped by the values in col1 (mean can be replaced with almost any function from the statistics section)
df.pivot_table(index=col1, values= col2,col3], aggfunc=mean) # Creates a pivot table that groups by col1 and calculates the mean of col2 and col3
df.groupby(col1).agg(np.mean) # Finds the average across all columns for every unique column 1 group
df.apply(np.<function>) # Applies a function across each column
df.apply(np.<function>, axis=1) # Applies a function across each row