diff --git a/README.md b/README.md index 75f701c37..daa8cd3fc 100644 --- a/README.md +++ b/README.md @@ -3220,11 +3220,28 @@ a 1 2 b 3 4 ``` +```python +x_col = [1, 3] +y_col = [2, 4] + = pd.DataFrame({'x': x_col, 'y': y_cal}, index=['a', 'b']) +.columns # Get the column names: {x, y} +.index # Get the index values: {a, b} +``` + ```python = pd.DataFrame() # Rows can be either lists, dicts or series. = pd.DataFrame() # Columns can be either lists, dicts or series. ``` +Descriptive information about dataframe: +```python +.head(n=5) # Return first n occurrences +.dtypes # Return data types of each columns +.isna/isnull() # Return empty values in +.describe() # Get statistical description of (both numeric & object) +``` + +For selection of multiple elements: ```python = .loc[row_key, column_key] # Or: .iloc[row_index, column_index] = .loc[row_key/s] # Or: .iloc[row_index/es] @@ -3232,6 +3249,11 @@ b 3 4 = .loc[row_bools, column_bools] # Or: .iloc[row_bools, column_bools] ``` +For selection of single element: +```python + = .at[row_index, column_key] +``` + ```python = [column_key/s] # Or: .column_key = [row_bools] # Keeps rows as specified by bools. @@ -3249,6 +3271,7 @@ b 3 4 = .sort_index(ascending=True) # Sorts rows by row keys. Use `axis=1` for cols. = .sort_values(column_key/s) # Sorts rows by the passed column/s. Same. ``` +Those methods have optional parameter *inplace*, which would make the changes in the object from they are called and return None. #### DataFrame — Merge, Join, Concat: ```python