Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandas #144

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3220,18 +3220,40 @@ a 1 2
b 3 4
```

```python
x_col = [1, 3]
y_col = [2, 4]
<DF> = pd.DataFrame({'x': x_col, 'y': y_cal}, index=['a', 'b'])
<DF>.columns # Get the column names: {x, y}
<DF>.index # Get the index values: {a, b}
```

```python
<DF> = pd.DataFrame(<list_of_rows>) # Rows can be either lists, dicts or series.
<DF> = pd.DataFrame(<dict_of_columns>) # Columns can be either lists, dicts or series.
```

Descriptive information about dataframe:
```python
<DF>.head(n=5) # Return first n occurrences
<DF>.dtypes # Return data types of each columns
<DF>.isna/isnull() # Return empty values in <DF>
<DF>.describe() # Get statistical description of <DF> (both numeric & object)
```

For selection of multiple elements:
```python
<el> = <DF>.loc[row_key, column_key] # Or: <DF>.iloc[row_index, column_index]
<Sr/DF> = <DF>.loc[row_key/s] # Or: <DF>.iloc[row_index/es]
<Sr/DF> = <DF>.loc[:, column_key/s] # Or: <DF>.iloc[:, column_index/es]
<DF> = <DF>.loc[row_bools, column_bools] # Or: <DF>.iloc[row_bools, column_bools]
```

For selection of single element:
```python
<el> = <DF>.at[row_index, column_key]
```

```python
<Sr/DF> = <DF>[column_key/s] # Or: <DF>.column_key
<DF> = <DF>[row_bools] # Keeps rows as specified by bools.
Expand All @@ -3249,6 +3271,7 @@ b 3 4
<DF> = <DF>.sort_index(ascending=True) # Sorts rows by row keys. Use `axis=1` for cols.
<DF> = <DF>.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
Expand Down