diff --git a/dox/conf.py b/dox/conf.py index 11a82cc5cfeb3bd0583931a2ea9ef96ed57d3669..52c7a69e55a079490941e3635fbecf3d2985846a 100644 --- a/dox/conf.py +++ b/dox/conf.py @@ -50,6 +50,7 @@ extensions = [ # markdown sources support 'recommonmark', + 'sphinx_markdown_tables', ] numpydoc_show_class_members = False automodsumm_inherited_members = True diff --git a/dox/indexing_help.md b/dox/indexing_help.md index f817081d824a59a2e4f5d5017150bcd05d3fd1d9..533dc2a583b52435e23febd732c88e6d18ef7ab7 100644 --- a/dox/indexing_help.md +++ b/dox/indexing_help.md @@ -22,14 +22,16 @@ each column separately. So maybe a first example gives an rough idea: ``` ->> d +>>> s = pd.Series([11] * 4 ) +>>> d = DictOfSeries(dict(a=s[:2]*6, b=s[2:4]*7, c=s[:2]*8, d=s[1:3]*9)) +>>> d a | b | c | d | ===== | ===== | ===== | ===== | 0 66 | 2 77 | 0 88 | 1 99 | 1 66 | 3 77 | 1 88 | 2 99 | ->> d.aloc[[1,2], ['a', 'b', 'd', 'x']] +>>> d.aloc[[1,2], ['a', 'b', 'd', 'x']] a | b | d | ===== | ===== | ===== | 1 66 | 2 77 | 1 99 | @@ -94,37 +96,44 @@ Indexer Table | example | type | on | like `.loc` | handling | conditions / hints | link | | ------- | ---- | --- | ----------- | -------- | ------------------ | ---- | | `.aloc[any, 'a']` | scalar | columns |no | select graceful | - | [cols](#select-columns-gracefully)| - - -fooo ----- -|[Column indexer](#select-columns-gracefully)| ---- | --- | ----------- | -------- | ------------------ | ---- | +|[Column indexer](#select-columns-gracefully)| | `.aloc[any, 'a']` | scalar | columns |no | select graceful | - | [cols](#select-columns-gracefully)| | `.aloc[any, 'b':'z']` | slice | columns |yes| slice | - | [cols](#select-columns-gracefully)| | `.aloc[any, ['a','c']]` | list-like | columns |no | filter graceful | - | [cols](#select-columns-gracefully)| | `.aloc[any [True,False]]` | bool list-like | columns |yes| take `True`'s | length must match nr of columns | [cols](#select-columns-gracefully)| -| `.aloc[any, s]` | pandas.Series | columns |no | like list, | only `s.values` are evaluated | [cols](#select-columns-gracefully)| -| `.aloc[any, bs]` | bool pandas.Series | columns |yes| like bool-list | see there | [cols](#select-columns-gracefully)| -|[Row indexer](#selecting-rows-a-smart-way)| ---- | --- | ----------- | -------- | ------------------ | ---- | +| `.aloc[any, s]` | Series | columns |no | like list, | only `s.values` are evaluated | [cols](#select-columns-gracefully)| +| `.aloc[any, bs]` | bool Series | columns |yes| like bool-list | see there | [cols](#select-columns-gracefully)| +|[Row indexer](#selecting-rows-a-smart-way)| | `.aloc[7, any]` | scalar | rows |no | translate to `.loc[key:key]` | - | [rows](#selecting-rows-a-smart-way) | | `.aloc[3:42, any]` | slice | rows |yes| slice | - | | | `.aloc[[1,2,24], any]` | list-like | rows |no | filter graceful | - | [rows](#selecting-rows-a-smart-way) | | `.aloc[[True,False], any]` | bool list-like | rows |yes| take `True`'s | length must match nr of (all selected) columns | [blist](#boolean-array-likes-as-row-indexer)| -| `.aloc[s, any]` | pandas.Series | rows |no | like `.loc[s.index]` | - | [ser](#pandasseries-and-boolean-pandasseries-as-row-indexer) | -| `.aloc[bs, any]` | bool pandas.Series | rows |no | align + just take `True`'s | evaluate `usebool`-keyword | [ser](#pandasseries-and-boolean-pandasseries-as-row-indexer)| +| `.aloc[s, any]` | Series | rows |no | like `.loc[s.index]` | - | [ser](#pandasseries-and-boolean-pandasseries-as-row-indexer) | +| `.aloc[bs, any]` | bool Series | rows |no | align + just take `True`'s | evaluate `usebool`-keyword | [ser](#pandasseries-and-boolean-pandasseries-as-row-indexer)| | `.aloc[[[s],[1,2,3]], any]` | nested list-like | both | ? | one row-indexer per column | outer length must match nr of (selected) columns | [nlist](#nested-lists-as-row-indexer) | -|[2D-indexer](#the-power-of-2d-indexer)| ---- | --- | ----------- | -------- | ------------------ | ---- | +|[2D-indexer](#the-power-of-2d-indexer)| | `.aloc[di]` | dios-like | both |no | full align | - | | | `.aloc[di, ...]` | dios-like | both |no | full align | ellipsis has no effect | | | `.aloc[di>5]` | bool dios-like | both |no | full align + take `True`'s | evaluate `usebool`-keyword | | | `.aloc[di>5, ...]` | (bool) dios-like | both |no | full align, **no** bool evaluation | - | | Example dios -============ +------------ The dios used in the examples, unless stated otherwise: ``` +# generate dict +>>> sa = pd.Series(range(0, 70, 7)) +>>> sb = pd.Series(range(5, 15, 1)) +>>> sc = pd.Series(range(7, 107, 10)) +>>> sd = pd.Series(range(0, 10, 1)) +>>> for i, s in enumerate([sa,sb,sc,sd]): s.index += i*2 +>>> d = DictOfSeries(dict(a=sa, b=sb, c=sc, d=sd))[:5] +``` + +Looks like so: +``` >>> d a | b | c | d | ===== | ==== | ===== | ===== | @@ -136,13 +145,13 @@ The dios used in the examples, unless stated otherwise: ``` Select columns, gracefully -=========================== +--------------------------- **Single columns** Use `.aloc[:, key]` to select a single column gracefully. -The underling pandas Series is returned, if the key exist. -Otherwise a empty pd.Series with `dtype=object` is returned. +The underling pandas.Series is returned, if the key exist. +Otherwise a empty pandas.Series with `dtype=object` is returned. ``` >>> d.aloc[:, 'a'] @@ -207,7 +216,7 @@ eg `.loc[:, 'a':'f']`. Selecting Rows a smart way -========================== +-------------------------- For scalar and array-like indexer with label values, the keys are handled gracefully, just like with array-like column indexers. @@ -255,8 +264,7 @@ If the length does not match a `IndexError` is raised: >>> d.aloc[[True,False,False]] Traceback (most recent call last): ... - f"Boolean index has wrong length: " -IndexError: failed for column a: Boolean index has wrong length: 3 instead of 5 + IndexError: failed for column a: Boolean index has wrong length: 3 instead of 5 ``` This can be tricky, especially if columns have different length: @@ -271,8 +279,7 @@ This can be tricky, especially if columns have different length: >>> difflen.aloc[[False,True,False]] Traceback (most recent call last): ... - f"Boolean index has wrong length: " -IndexError: Boolean index has wrong length: 3 instead of 2 + IndexError: Boolean index has wrong length: 3 instead of 2 ``` pandas.Series and boolean pandas.Series as row indexer @@ -401,7 +408,7 @@ In contrast to the 2D-indexer, we also can provide a column key, to pre-filter t The power of 2D-indexer -======================= +----------------------- Overview: