From b05b8419d5cf602492f3d83523b650487b9f57f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 24 Jul 2022 15:30:26 +0200 Subject: [PATCH] Struct, Logging, Image draw, a lot of changes in Pandas --- README.md | 134 +++++++++++++++++++++++++-------------------------- index.html | 138 ++++++++++++++++++++++++++--------------------------- parse.js | 6 +-- 3 files changed, 139 insertions(+), 139 deletions(-) diff --git a/README.md b/README.md index 9dd19e5..69bfac4 100644 --- a/README.md +++ b/README.md @@ -1998,7 +1998,7 @@ b'\x00\x01\x00\x02\x00\x00\x00\x03' * **`'>'` - Big-endian (also `'!'`).** #### Besides numbers, pack() and unpack() also support bytes objects as part of the sequence: -* **`'c'` - A bytes object with a single element. Use `'x'` for pad byte.** +* **`'c'` - A bytes object with a single element. For pad byte use `'x'`.** * **`'s'` - A bytes object with n elements.** #### Integer types. Use a capital letter for unsigned type. Minimum and standard sizes are in brackets: @@ -2445,7 +2445,7 @@ from loguru import logger ```python logger.add('debug_{time}.log', colorize=True) # Connects a log file. logger.add('error_{time}.log', level='ERROR') # Another file for errors or higher. -logger.('A logging message.') +logger.('A logging message.') # Logs to file/s and prints to stderr. ``` * **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical'`.** @@ -2787,12 +2787,12 @@ from PIL import ImageDraw ``` ```python -.point((x, y)) -.line((x1, y1, x2, y2 [, ...])) -.arc((x1, y1, x2, y2), from_deg, to_deg) -.rectangle((x1, y1, x2, y2)) -.polygon((x1, y1, x2, y2, ...)) -.ellipse((x1, y1, x2, y2)) +.point((x, y)) # Truncates floats into ints. +.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use images's resize(). +.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction. +.rectangle((x1, y1, x2, y2)) # To rotate use image's rotate() and paste(). +.polygon((x1, y1, x2, y2, ...)) # Last and first point get connected. +.ellipse((x1, y1, x2, y2)) # To rotate use image's rotate() and paste(). ``` * **Use `'fill='` to set the primary color.** * **Use `'width='` to set the width of lines or contours.** @@ -3121,44 +3121,44 @@ Name: a, dtype: int64 ``` ```python - = Series() # Assigns RangeIndex starting at 0. - = Series() # Takes dictionary's keys for index. - = Series(, index=) # Only keeps items with keys specified in index. + = Series() # Assigns RangeIndex starting at 0. + = Series() # Takes dictionary's keys for index. + = Series(, index=) # Only keeps items with keys specified in index. ``` ```python - = .loc[key] # Or: .iloc[index] - = .loc[keys] # Or: .iloc[indexes] - = .loc[from_key : to_key_inclusive] # Or: .iloc[from_i : to_i_exclusive] + = .loc[key] # Or: .iloc[index] + = .loc[keys] # Or: .iloc[indexes] + = .loc[from_key : to_key_inclusive] # Or: .iloc[from_i : to_i_exclusive] ``` ```python - = [key/index] # Or: .key - = [keys/indexes] # Or: [] - = [bools] # Or: .i/loc[bools] + = [key/index] # Or: .key + = [keys/indexes] # Or: [] + = [bools] # Or: .i/loc[bools] ``` ```python - = ><== # Returns a Series of bools. - = +-*/ # Items with non-matching keys get value NaN. + = ><== # Returns a Series of bools. + = +-*/ # Items with non-matching keys get value NaN. ``` ```python - = .append() # Or: pd.concat() - = .combine_first() # Adds items that are not yet present. -.update() # Updates items that are already present. + = .append() # Or: pd.concat() + = .combine_first() # Adds items that are not yet present. +.update() # Updates items that are already present. ``` ```python -.plot.line/area/bar/pie/hist() # Generates a Matplotlib plot. -matplotlib.pyplot.show() # Displays the plot. Also savefig(). +.plot.line/area/bar/pie/hist() # Generates a Matplotlib plot. +matplotlib.pyplot.show() # Displays the plot. Also savefig(). ``` #### Series — Aggregate, Transform, Map: ```python - = .sum/max/mean/idxmax/all() # Or: .agg(lambda : ) - = .rank/diff/cumsum/ffill/interpl() # Or: .agg/transform(lambda : ) - = .fillna() # Or: .agg/transform/map(lambda : ) + = .sum/max/mean/idxmax/all() # Or: .agg(lambda : ) + = .rank/diff/cumsum/ffill/interpl() # Or: .agg/transform(lambda : ) + = .fillna() # Or: .agg/transform/map(lambda : ) ``` ```python @@ -3198,33 +3198,33 @@ b 3 4 ``` ```python - = DataFrame() # Rows can be either lists, dicts or series. - = DataFrame() # Columns can be either lists, dicts or series. + = DataFrame() # Rows can be either lists, dicts or series. + = DataFrame() # Columns can be either lists, dicts or series. ``` ```python - = .loc[row_key, column_key] # Or: .iloc[row_index, column_index] - = .loc[row_key/s] # Or: .iloc[row_index/es] - = .loc[:, column_key/s] # Or: .iloc[:, column_index/es] - = .loc[row_bools, column_bools] # Or: .iloc[row_bools, column_bools] + = .loc[row_key, column_key] # Or: .iloc[row_index, column_index] + = .loc[row_key/s] # Or: .iloc[row_index/es] + = .loc[:, column_key/s] # Or: .iloc[:, column_index/es] + = .loc[row_bools, column_bools] # Or: .iloc[row_bools, column_bools] ``` ```python - = [column_key/s] # Or: .column_key - = [row_bools] # Keeps rows as specified by bools. - = [] # Assigns NaN to False values. + = [column_key/s] # Or: .column_key + = [row_bools] # Keeps rows as specified by bools. + = [] # Assigns NaN to False values. ``` ```python - = ><== # Returns DF of bools. Sr is treated as a row. - = +-*/ # Items with non-matching keys get value NaN. + = ><== # Returns DF of bools. Sr is treated as a row. + = +-*/ # Items with non-matching keys get value NaN. ``` ```python - = .set_index(column_key) # Replaces row keys with values from a column. - = .reset_index() # Moves row keys to a column named index. - = .sort_index(ascending=True) # Sorts rows by row keys. - = .sort_values(column_key/s) # Sorts rows by the passed column/s. + = .set_index(column_key) # Replaces row keys with values from a column. + = .reset_index() # Moves row keys to a column named index. + = .sort_index(ascending=True) # Sorts rows by row keys. + = .sort_values(column_key/s) # Sorts rows by the passed column/s. ``` #### DataFrame — Merge, Join, Concat: @@ -3250,18 +3250,18 @@ c 6 7 +------------------------+---------------+------------+------------+--------------------------+ | l.join(r, lsuffix='l', | x yl yr z | | x yl yr z | Joins/merges on row keys.| | rsuffix='r', | a 1 2 . . | x yl yr z | 1 2 . . | Uses 'left' by default. | -| how=…) | b 3 4 4 5 | 3 4 4 5 | 3 4 4 5 | If r is a series, it is | +| how=…) | b 3 4 4 5 | 3 4 4 5 | 3 4 4 5 | If r is a Series, it is | | | c . . 6 7 | | | treated as a column. | +------------------------+---------------+------------+------------+--------------------------+ | pd.concat([l, r], | x y z | y | | Adds rows at the bottom. | | axis=0, | a 1 2 . | 2 | | Uses 'outer' by default. | -| join=…) | b 3 4 . | 4 | | A series is treated as a | +| join=…) | b 3 4 . | 4 | | A Series is treated as a | | | b . 4 5 | 4 | | column. Use l.append(sr) | | | c . 6 7 | 6 | | to add a row instead. | +------------------------+---------------+------------+------------+--------------------------+ | pd.concat([l, r], | x y y z | | | Adds columns at the | | axis=1, | a 1 2 . . | x y y z | | right end. Uses 'outer' | -| join=…) | b 3 4 4 5 | 3 4 4 5 | | by default. A series is | +| join=…) | b 3 4 4 5 | 3 4 4 5 | | by default. A Series is | | | c . . 6 7 | | | treated as a column. | +------------------------+---------------+------------+------------+--------------------------+ | l.combine_first(r) | x y z | | | Adds missing rows and | @@ -3273,9 +3273,9 @@ c 6 7 #### DataFrame — Aggregate, Transform, Map: ```python - = .sum/max/mean/idxmax/all() # Or: .apply/agg(lambda : ) - = .rank/diff/cumsum/ffill/interpl() # Or: .apply/agg/transform(lambda : ) - = .fillna() # Or: .applymap(lambda : ) + = .sum/max/mean/idxmax/all() # Or: .apply/agg(lambda : ) + = .rank/diff/cumsum/ffill/interpl() # Or: .apply/agg/transfrm(lambda : ) + = .fillna() # Or: .applymap(lambda : ) ``` * **All operations operate on columns by default. Pass `'axis=1'` to process the rows instead.** @@ -3310,22 +3310,22 @@ b 3 4 #### DataFrame — Plot, Encode, Decode: ```python -import matplotlib.pyplot as plt -.plot.line/bar/hist/scatter([x=column_key, y=column_key/s]); plt.show() +.plot.line/bar/hist/scatter() # Also: `x=column_key, y=column_key/s`. +import matplotlib.pyplot as plt; plt.show() # Displays the plot. ``` ```python - = pd.read_json/html('') - = pd.read_csv/pickle/excel('') - = pd.read_sql('', ) - = pd.read_clipboard() + = pd.read_json/html('') # Run `$ pip3 install lxml` to read html. + = pd.read_csv/pickle/excel('') # Use `sheet_name=None` to get all Excel sheets. + = pd.read_sql('', ) # Accepts SQLite3 or SQLAlchemy connection. + = pd.read_clipboard() # Reads a copied table from the clipboard. ``` ```python - = .to_dict(['d/l/s/sp/r/i']) - = .to_json/html/csv/markdown/latex([]) -.to_pickle/excel() -.to_sql('', ) + = .to_dict(['d/l/s/…']) # Returns columns as dicts, lists or series. + = .to_json/html/csv([]) # Also to_markdown/latex([]). +.to_pickle/excel() # Run `$ pip3 install openpyxl` for xlsx files. +.to_sql('', ) # Accepts SQLite3 or SQLAlchemy connection. ``` ### GroupBy @@ -3340,16 +3340,16 @@ c 7 8 ``` ```python - = .groupby(column_key/s) # DF is split into groups based on passed column. - = .apply() # Maps each group. Func can return DF, Sr or el. - = [column_key] # A single column GB. All operations return a Sr. + = .groupby(column_key/s) # Splits DF into groups based on passed column. + = .apply() # Maps each group. Func can return DF, Sr or el. + = [column_key] # Single column GB. All operations return a Sr. ``` #### GroupBy — Aggregate, Transform, Map: ```python - = .sum/max/mean/idxmax/all() # Or: .agg(lambda : ) - = .rank/diff/cumsum/ffill() # Or: .transform(lambda : ) - = .fillna() # Or: .transform(lambda : ) + = .sum/max/mean/idxmax/all() # Or: .agg(lambda : ) + = .rank/diff/cumsum/ffill() # Or: .transform(lambda : ) + = .fillna() # Or: .transform(lambda : ) ``` ```python @@ -3381,9 +3381,9 @@ c 7 8 **Object for rolling window calculations.** ```python - = .rolling(window_size) # Also: `min_periods=None, center=False`. - = [column_key/s] # Or: .column_key - = .sum/max/mean() # Or: .apply/agg() + = .rolling(win_size) # Also: `min_periods=None, center=False`. + = [column_key/s] # Or: .column_key + = .mean/sum/max() # Or: .apply/agg() ``` diff --git a/index.html b/index.html index bc64634..c95e521 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1657,7 +1657,7 @@ CompletedProcess(args=['bc', '<' - Little-endian.
  • '>' - Big-endian (also '!').
  • Besides numbers, pack() and unpack() also support bytes objects as part of the sequence:

      -
    • 'c' - A bytes object with a single element. Use 'x' for pad byte.
    • +
    • 'c' - A bytes object with a single element. For pad byte use 'x'.
    • '<n>s' - A bytes object with n elements.

    Integer types. Use a capital letter for unsigned type. Minimum and standard sizes are in brackets:

    • 'b' - char (1/1)
    • @@ -2007,7 +2007,7 @@ print(table)
      logger.add('debug_{time}.log', colorize=True)  # Connects a log file.
       logger.add('error_{time}.log', level='ERROR')  # Another file for errors or higher.
      -logger.<level>('A logging message.')
      +logger.<level>('A logging message.')           # Logs to file/s and prints to stderr.
       
      • Levels: 'debug', 'info', 'success', 'warning', 'error', 'critical'.
      • @@ -2273,12 +2273,12 @@ img.convert('RGB').save(<ImageDraw>.point((x, y)) -<ImageDraw>.line((x1, y1, x2, y2 [, ...])) -<ImageDraw>.arc((x1, y1, x2, y2), from_deg, to_deg) -<ImageDraw>.rectangle((x1, y1, x2, y2)) -<ImageDraw>.polygon((x1, y1, x2, y2, ...)) -<ImageDraw>.ellipse((x1, y1, x2, y2)) +
        <ImageDraw>.point((x, y))                       # Truncates floats into ints.
        +<ImageDraw>.line((x1, y1, x2, y2 [, ...]))      # To get anti-aliasing use images's resize().
        +<ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2)   # Always draws in clockwise direction.
        +<ImageDraw>.rectangle((x1, y1, x2, y2))         # To rotate use image's rotate() and paste().
        +<ImageDraw>.polygon((x1, y1, x2, y2, ...))      # Last and first point get connected.
        +<ImageDraw>.ellipse((x1, y1, x2, y2))           # To rotate use image's rotate() and paste().
         
        • Use 'fill=<color>' to set the primary color.
        • @@ -2550,31 +2550,31 @@ Name: a, dtype: int64
    -
    <Sr> = Series(<list>)                         # Assigns RangeIndex starting at 0.
    -<Sr> = Series(<dict>)                         # Takes dictionary's keys for index.
    -<Sr> = Series(<dict/Series>, index=<list>)    # Only keeps items with keys specified in index.
    +
    <Sr> = Series(<list>)                          # Assigns RangeIndex starting at 0.
    +<Sr> = Series(<dict>)                          # Takes dictionary's keys for index.
    +<Sr> = Series(<dict/Series>, index=<list>)     # Only keeps items with keys specified in index.
     
    -
    <el> = <Sr>.loc[key]                          # Or: <Sr>.iloc[index]
    -<Sr> = <Sr>.loc[keys]                         # Or: <Sr>.iloc[indexes]
    -<Sr> = <Sr>.loc[from_key : to_key_inclusive]  # Or: <Sr>.iloc[from_i : to_i_exclusive]
    +
    <el> = <Sr>.loc[key]                           # Or: <Sr>.iloc[index]
    +<Sr> = <Sr>.loc[keys]                          # Or: <Sr>.iloc[indexes]
    +<Sr> = <Sr>.loc[from_key : to_key_inclusive]   # Or: <Sr>.iloc[from_i : to_i_exclusive]
     
    -
    <el> = <Sr>[key/index]                        # Or: <Sr>.key
    -<Sr> = <Sr>[keys/indexes]                     # Or: <Sr>[<key_range/range>]
    -<Sr> = <Sr>[bools]                            # Or: <Sr>.i/loc[bools]
    +
    <el> = <Sr>[key/index]                         # Or: <Sr>.key
    +<Sr> = <Sr>[keys/indexes]                      # Or: <Sr>[<key_range/range>]
    +<Sr> = <Sr>[bools]                             # Or: <Sr>.i/loc[bools]
     
    -
    <Sr> = <Sr> ><== <el/Sr>                      # Returns a Series of bools.
    -<Sr> = <Sr> +-*/ <el/Sr>                      # Items with non-matching keys get value NaN.
    +
    <Sr> = <Sr> ><== <el/Sr>                       # Returns a Series of bools.
    +<Sr> = <Sr> +-*/ <el/Sr>                       # Items with non-matching keys get value NaN.
     
    -
    <Sr> = <Sr>.append(<Sr>)                      # Or: pd.concat(<coll_of_Sr>)
    -<Sr> = <Sr>.combine_first(<Sr>)               # Adds items that are not yet present.
    -<Sr>.update(<Sr>)                             # Updates items that are already present.
    +
    <Sr> = <Sr>.append(<Sr>)                       # Or: pd.concat(<coll_of_Sr>)
    +<Sr> = <Sr>.combine_first(<Sr>)                # Adds items that are not yet present.
    +<Sr>.update(<Sr>)                              # Updates items that are already present.
     
    -
    <Sr>.plot.line/area/bar/pie/hist()            # Generates a Matplotlib plot.
    -matplotlib.pyplot.show()                      # Displays the plot. Also savefig(<path>).
    +
    <Sr>.plot.line/area/bar/pie/hist()             # Generates a Matplotlib plot.
    +matplotlib.pyplot.show()                       # Displays the plot. Also savefig(<path>).
     
    -

    Series — Aggregate, Transform, Map:

    <el> = <Sr>.sum/max/mean/idxmax/all()         # Or: <Sr>.agg(lambda <Sr>: <el>)
    -<Sr> = <Sr>.rank/diff/cumsum/ffill/interpl()  # Or: <Sr>.agg/transform(lambda <Sr>: <Sr>)
    -<Sr> = <Sr>.fillna(<el>)                      # Or: <Sr>.agg/transform/map(lambda <el>: <el>)
    +

    Series — Aggregate, Transform, Map:

    <el> = <Sr>.sum/max/mean/idxmax/all()          # Or: <Sr>.agg(lambda <Sr>: <el>)
    +<Sr> = <Sr>.rank/diff/cumsum/ffill/interpl()   # Or: <Sr>.agg/transform(lambda <Sr>: <Sr>)
    +<Sr> = <Sr>.fillna(<el>)                       # Or: <Sr>.agg/transform/map(lambda <el>: <el>)
     
    >>> sr = Series([1, 2], index=['x', 'y'])
    @@ -2607,25 +2607,25 @@ b  3  4
     
    -
    <DF>    = DataFrame(<list_of_rows>)           # Rows can be either lists, dicts or series.
    -<DF>    = DataFrame(<dict_of_columns>)        # Columns can be either lists, dicts or series.
    +
    <DF>    = DataFrame(<list_of_rows>)            # Rows can be either lists, dicts or series.
    +<DF>    = DataFrame(<dict_of_columns>)         # Columns can be either lists, dicts or series.
     
    -
    <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]
    +
    <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]
     
    -
    <Sr/DF> = <DF>[column_key/s]                  # Or: <DF>.column_key
    -<DF>    = <DF>[row_bools]                     # Keeps rows as specified by bools.
    -<DF>    = <DF>[<DF_of_bools>]                 # Assigns NaN to False values.
    +
    <Sr/DF> = <DF>[column_key/s]                   # Or: <DF>.column_key
    +<DF>    = <DF>[row_bools]                      # Keeps rows as specified by bools.
    +<DF>    = <DF>[<DF_of_bools>]                  # Assigns NaN to False values.
     
    -
    <DF>    = <DF> ><== <el/Sr/DF>                # Returns DF of bools. Sr is treated as a row.
    -<DF>    = <DF> +-*/ <el/Sr/DF>                # Items with non-matching keys get value NaN.
    +
    <DF>    = <DF> ><== <el/Sr/DF>                 # Returns DF of bools. Sr is treated as a row.
    +<DF>    = <DF> +-*/ <el/Sr/DF>                 # Items with non-matching keys get value NaN.
     
    -
    <DF>    = <DF>.set_index(column_key)          # Replaces row keys with values from a column.
    -<DF>    = <DF>.reset_index()                  # Moves row keys to a column named index.
    -<DF>    = <DF>.sort_index(ascending=True)     # Sorts rows by row keys.
    -<DF>    = <DF>.sort_values(column_key/s)      # Sorts rows by the passed column/s.
    +
    <DF>    = <DF>.set_index(column_key)           # Replaces row keys with values from a column.
    +<DF>    = <DF>.reset_index()                   # Moves row keys to a column named index.
    +<DF>    = <DF>.sort_index(ascending=True)      # Sorts rows by row keys.
    +<DF>    = <DF>.sort_values(column_key/s)       # Sorts rows by the passed column/s.
     

    DataFrame — Merge, Join, Concat:

    >>> l = DataFrame([[1, 2], [3, 4]], index=['a', 'b'], columns=['x', 'y'])
        x  y
    @@ -2647,18 +2647,18 @@ c  6  7
     ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
     ┃ l.join(r, lsuffix='l', │    x yl yr  z │            │ x yl yr  z │ Joins/merges on row keys.┃
     ┃           rsuffix='r', │ a  1  2  .  . │ x yl yr  z │ 1  2  .  . │ Uses 'left' by default.  ┃
    -┃           how=…)       │ b  3  4  4  53  4  4  53  4  4  5 │ If r is a series, it is  ┃
    +┃           how=…)       │ b  3  4  4  53  4  4  53  4  4  5 │ If r is a Series, it is  ┃
     ┃                        │ c  .  .  6  7 │            │            │ treated as a column.     ┃
     ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
     ┃ pd.concat([l, r],      │    x   y   z  │     y      │            │ Adds rows at the bottom. ┃
     ┃           axis=0,      │ a  1   2   .  │     2      │            │ Uses 'outer' by default. ┃
    -┃           join=…)      │ b  3   4   .  │     4      │            │ A series is treated as a ┃
    +┃           join=…)      │ b  3   4   .  │     4      │            │ A Series is treated as a ┃
     ┃                        │ b  .   4   54      │            │ column. Use l.append(sr) ┃
     ┃                        │ c  .   6   76      │            │ to add a row instead.    ┃
     ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
     ┃ pd.concat([l, r],      │    x  y  y  z │            │            │ Adds columns at the      ┃
     ┃           axis=1,      │ a  1  2  .  . │ x  y  y  z │            │ right end. Uses 'outer'  ┃
    -┃           join=…)      │ b  3  4  4  53  4  4  5 │            │ by default. A series is  ┃
    +┃           join=…)      │ b  3  4  4  53  4  4  5 │            │ by default. A Series is  ┃
     ┃                        │ c  .  .  6  7 │            │            │ treated as a column.     ┃
     ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
     ┃ l.combine_first(r)     │    x   y   z  │            │            │ Adds missing rows and    ┃
    @@ -2667,9 +2667,9 @@ c  6  7
     ┃                        │ c  .   6   7  │            │            │ R must be a DataFrame.   ┃
     ┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
     
    -

    DataFrame — Aggregate, Transform, Map:

    <Sr> = <DF>.sum/max/mean/idxmax/all()         # Or: <DF>.apply/agg(lambda <Sr>: <el>)
    -<DF> = <DF>.rank/diff/cumsum/ffill/interpl()  # Or: <DF>.apply/agg/transform(lambda <Sr>: <Sr>)
    -<DF> = <DF>.fillna(<el>)                      # Or: <DF>.applymap(lambda <el>: <el>)
    +

    DataFrame — Aggregate, Transform, Map:

    <Sr> = <DF>.sum/max/mean/idxmax/all()          # Or: <DF>.apply/agg(lambda <Sr>: <el>)
    +<DF> = <DF>.rank/diff/cumsum/ffill/interpl()   # Or: <DF>.apply/agg/transfrm(lambda <Sr>: <Sr>)
    +<DF> = <DF>.fillna(<el>)                       # Or: <DF>.applymap(lambda <el>: <el>)
     
      @@ -2701,19 +2701,19 @@ b 3 4
      • Use '<DF>[col_key_1, col_key_2][row_key]' to get the fifth result's values.
      -

      DataFrame — Plot, Encode, Decode:

      import matplotlib.pyplot as plt
      -<DF>.plot.line/bar/hist/scatter([x=column_key, y=column_key/s]); plt.show()
      +

      DataFrame — Plot, Encode, Decode:

      <DF>.plot.line/bar/hist/scatter()              # Also: `x=column_key, y=column_key/s`.
      +import matplotlib.pyplot as plt; plt.show()    # Displays the plot.
       
      -
      <DF> = pd.read_json/html('<str/path/url>')
      -<DF> = pd.read_csv/pickle/excel('<path/url>')
      -<DF> = pd.read_sql('<table_name/query>', <connection>)
      -<DF> = pd.read_clipboard()
      +
      <DF> = pd.read_json/html('<str/path/url>')     # Run `$ pip3 install lxml` to read html.
      +<DF> = pd.read_csv/pickle/excel('<path/url>')  # Use `sheet_name=None` to get all Excel sheets.
      +<DF> = pd.read_sql('<table/query>', <conn.>)   # Accepts SQLite3 or SQLAlchemy connection.
      +<DF> = pd.read_clipboard()                     # Reads a copied table from the clipboard.
       
      -
      <dict> = <DF>.to_dict(['d/l/s/sp/r/i'])
      -<str>  = <DF>.to_json/html/csv/markdown/latex([<path>])
      -<DF>.to_pickle/excel(<path>)
      -<DF>.to_sql('<table_name>', <connection>)
      +
      <dict> = <DF>.to_dict(['d/l/s/…'])             # Returns columns as dicts, lists or series.
      +<str>  = <DF>.to_json/html/csv([<path>])       # Also to_markdown/latex([<path>]).
      +<DF>.to_pickle/excel(<path>)                   # Run `$ pip3 install openpyxl` for xlsx files.
      +<DF>.to_sql('<table_name>', <connection>)      # Accepts SQLite3 or SQLAlchemy connection.
       

      GroupBy

      Object that groups together rows of a dataframe based on the value of the passed column.

      >>> df = DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 6]], index=list('abc'), columns=list('xyz'))
       >>> df.groupby('z').get_group(6)
      @@ -2723,13 +2723,13 @@ c  7  8
       
      -
      <GB> = <DF>.groupby(column_key/s)             # DF is split into groups based on passed column.
      -<DF> = <GB>.apply(<func>)                     # Maps each group. Func can return DF, Sr or el.
      -<GB> = <GB>[column_key]                       # A single column GB. All operations return a Sr.
      +
      <GB> = <DF>.groupby(column_key/s)              # Splits DF into groups based on passed column.
      +<DF> = <GB>.apply(<func>)                      # Maps each group. Func can return DF, Sr or el.
      +<GB> = <GB>[column_key]                        # Single column GB. All operations return a Sr.
       
      -

      GroupBy — Aggregate, Transform, Map:

      <DF> = <GB>.sum/max/mean/idxmax/all()         # Or: <GB>.agg(lambda <Sr>: <el>)
      -<DF> = <GB>.rank/diff/cumsum/ffill()          # Or: <GB>.transform(lambda <Sr>: <Sr>)
      -<DF> = <GB>.fillna(<el>)                      # Or: <GB>.transform(lambda <Sr>: <Sr>)
      +

      GroupBy — Aggregate, Transform, Map:

      <DF> = <GB>.sum/max/mean/idxmax/all()          # Or: <GB>.agg(lambda <Sr>: <el>)
      +<DF> = <GB>.rank/diff/cumsum/ffill()           # Or: <GB>.transform(lambda <Sr>: <Sr>)
      +<DF> = <GB>.fillna(<el>)                       # Or: <GB>.transform(lambda <Sr>: <Sr>)
       
      >>> gb = df.groupby('z')
      @@ -2753,9 +2753,9 @@ c  7  8
       ┃                 │  c  11  13  │   c  2  2   │             │               ┃
       ┗━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
       
      -

      Rolling

      Object for rolling window calculations.

      <R_Sr/R_DF/R_GB> = <Sr/DF/GB>.rolling(window_size)  # Also: `min_periods=None, center=False`.
      -<R_Sr/R_DF>      = <R_DF/R_GB>[column_key/s]        # Or: <R>.column_key
      -<Sr/DF/DF>       = <R_Sr/R_DF/R_GB>.sum/max/mean()  # Or: <R>.apply/agg(<agg_func/str>)
      +

      Rolling

      Object for rolling window calculations.

      <RSr/RDF/RGB> = <Sr/DF/GB>.rolling(win_size)   # Also: `min_periods=None, center=False`.
      +<RSr/RDF/RGB> = <RDF/RGB>[column_key/s]        # Or: <RDF/RGB>.column_key
      +<Sr/DF>       = <R>.mean/sum/max()             # Or: <R>.apply/agg(<agg_func/str>)
       
      @@ -2905,7 +2905,7 @@ $ pyinstaller script.py --add-data '<path>:.' diff --git a/parse.js b/parse.js index af5307c..f5cb4af 100755 --- a/parse.js +++ b/parse.js @@ -498,18 +498,18 @@ const DIAGRAM_15_B = "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┃ l.join(r, lsuffix='l', │ x yl yr z │ │ x yl yr z │ Joins/merges on row keys.┃\n" + "┃ rsuffix='r', │ a 1 2 . . │ x yl yr z │ 1 2 . . │ Uses 'left' by default. ┃\n" + - "┃ how=…) │ b 3 4 4 5 │ 3 4 4 5 │ 3 4 4 5 │ If r is a series, it is ┃\n" + + "┃ how=…) │ b 3 4 4 5 │ 3 4 4 5 │ 3 4 4 5 │ If r is a Series, it is ┃\n" + "┃ │ c . . 6 7 │ │ │ treated as a column. ┃\n" + "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃\n" + "┃ axis=0, │ a 1 2 . │ 2 │ │ Uses 'outer' by default. ┃\n" + - "┃ join=…) │ b 3 4 . │ 4 │ │ A series is treated as a ┃\n" + + "┃ join=…) │ b 3 4 . │ 4 │ │ A Series is treated as a ┃\n" + "┃ │ b . 4 5 │ 4 │ │ column. Use l.append(sr) ┃\n" + "┃ │ c . 6 7 │ 6 │ │ to add a row instead. ┃\n" + "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃\n" + "┃ axis=1, │ a 1 2 . . │ x y y z │ │ right end. Uses 'outer' ┃\n" + - "┃ join=…) │ b 3 4 4 5 │ 3 4 4 5 │ │ by default. A series is ┃\n" + + "┃ join=…) │ b 3 4 4 5 │ 3 4 4 5 │ │ by default. A Series is ┃\n" + "┃ │ c . . 6 7 │ │ │ treated as a column. ┃\n" + "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┃ l.combine_first(r) │ x y z │ │ │ Adds missing rows and ┃\n" +