`new_df=df.iloc[row_i1:row_i2, col_i]``new_df=df.iloc[[row_i1,row_i2,row_i3], [col_i1,col_i2]]` | get or set values in dataframe sub-range. returns a dataframe. |
| .columns | col_titles_list = df.columns | get list of the column titles (headers) |
| `columns.get_loc()` | `col_i=df.columns.get_loc(col_name_s)` | get index of column by name (string) |
| `at[]` | `df.at[row_s, col_s]` | get or set value in a **single** cell, by row and column names |
| `iat[]` | `df.iat[row_i, col_i]` | get or set value in a **single** cell, by row and column integer index |
| drop() | new_df = df.drop('row_title_to_drop')new_df = df.drop(list_of_row_titles_to_drop)new_df = df.drop(index=2)new_df = df.drop(index=[3,4,6]) | function that returns a dataframe in which the row(s) have been removed. |
| equals() | same_data_b = df1.equals(df2) | function that returns a boolean, True if dataframes have the same information, otherwise returns False |
| columns.get_loc() | (example?) | get integer location of column, by its name |
| index.get_loc() | (example?) | get integer location of row, by its name |
| .sort_values(column_name) | output_df = df.sort_values(col_name)\\ output_df = df.sort_values(by=[col_name_1, col_name_2, ...], ascending=True) | sort DataFrame by given column(s)\\ NOTE: row-titles also move, so use iloc instead of loc|
import pandas # pip install pandas