From a821b2b55b18c74b7a5feda4f210ecbcac45d9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 3 Dec 2024 05:48:10 +0100 Subject: [PATCH] Pandas --- README.md | 84 +++++++++++++++++++++++++-------------------------- index.html | 88 ++++++++++++++++++++++++++--------------------------- parse.js | 89 ++++++++++++++++++++++++++++-------------------------- 3 files changed, 133 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index fdcbdc9..82ed910 100644 --- a/README.md +++ b/README.md @@ -3231,7 +3231,7 @@ plt.show() # Displays the plot. Also plt.sav **Table with labeled rows and columns.** ```python ->>> l = pd.DataFrame([[1, 2], [3, 4]], index=['a', 'b'], columns=['x', 'y']); l +>>> df = pd.DataFrame([[1, 2], [3, 4]], index=['a', 'b'], columns=['x', 'y']); df x y a 1 2 b 3 4 @@ -3251,7 +3251,7 @@ b 3 4 ```python = [col_key/s] # Or: . - = [row_bools] # Keeps rows as specified by bools. + = [] # Filters rows. For example `df[df.x > 1]`. = [] # Assigns NaN to items that are False in bools. ``` @@ -3270,7 +3270,7 @@ b 3 4 ```python = .head/tail/sample() # Returns first, last, or random n rows. = .describe() # Describes columns. Also info(), corr(), shape. - = .query('') # Filters rows with e.g. 'col_1 == val_1 and …'. + = .query('') # Filters rows. For example `df.query('x > 1')`. ``` ```python @@ -3280,37 +3280,37 @@ plt.show() # Displays the plot. Also plt.sav #### DataFrame — Merge, Join, Concat: ```python ->>> r = pd.DataFrame([[4, 5], [6, 7]], index=['b', 'c'], columns=['y', 'z']); r +>>> df_2 = pd.DataFrame([[4, 5], [6, 7]], index=['b', 'c'], columns=['y', 'z']); df_2 y z b 4 5 c 6 7 ``` ```text -+------------------------+---------------+------------+------------+--------------------------+ -| | 'outer' | 'inner' | 'left' | Description | -+------------------------+---------------+------------+------------+--------------------------+ -| l.merge(r, on='y', | x y z | x y z | x y z | Merges on column if 'on' | -| how=…) | 0 1 2 . | 3 4 5 | 1 2 . | or 'left/right_on' are | -| | 1 3 4 5 | | 3 4 5 | set, else on shared cols.| -| | 2 . 6 7 | | | Uses 'inner' by default. | -+------------------------+---------------+------------+------------+--------------------------+ -| l.join(r, lsuffix='l', | x yl yr z | | x yl yr z | 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 | -| | 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 | -| | b . 4 5 | 4 | | column. To add a row use | -| | c . 6 7 | 6 | | pd.concat([l, DF([s])]). | -+------------------------+---------------+------------+------------+--------------------------+ -| 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 | -| | c . . 6 7 | | | treated as a column. | -+------------------------+---------------+------------+------------+--------------------------+ ++-----------------------+---------------+------------+------------+---------------------------+ +| | 'outer' | 'inner' | 'left' | Description | ++-----------------------+---------------+------------+------------+---------------------------+ +| df.merge(df_2, | x y z | x y z | x y z | Merges on column if 'on' | +| on='y', | 0 1 2 . | 3 4 5 | 1 2 . | or 'left/right_on' are | +| how=…) | 1 3 4 5 | | 3 4 5 | set, else on shared cols. | +| | 2 . 6 7 | | | Uses 'inner' by default. | ++-----------------------+---------------+------------+------------+---------------------------+ +| df.join(df_2, | x yl yr z | | x yl yr z | Merges on row keys. | +| lsuffix='l', | a 1 2 . . | x yl yr z | 1 2 . . | Uses 'left' by default. | +| rsuffix='r', | b 3 4 4 5 | 3 4 4 5 | 3 4 4 5 | If r is a Series, it is | +| how=…) | c . . 6 7 | | | treated as a column. | ++-----------------------+---------------+------------+------------+---------------------------+ +| pd.concat([df, df_2], | 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 | +| | b . 4 5 | 4 | | column. To add a row use | +| | c . 6 7 | 6 | | pd.concat([df, DF([s])]). | ++-----------------------+---------------+------------+------------+---------------------------+ +| pd.concat([df, df_2], | 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 | +| | c . . 6 7 | | | treated as a column. | ++-----------------------+---------------+------------+------------+---------------------------+ ``` #### DataFrame — Aggregate, Transform, Map: @@ -3321,23 +3321,23 @@ c 6 7 ``` ```text -+----------------+---------------+---------------+---------------+ -| | 'sum' | ['sum'] | {'x': 'sum'} | -+----------------+---------------+---------------+---------------+ -| l.apply(…) | x 4 | x y | x 4 | -| l.agg(…) | y 6 | sum 4 6 | | -+----------------+---------------+---------------+---------------+ ++-----------------+---------------+---------------+---------------+ +| | 'sum' | ['sum'] | {'x': 'sum'} | ++-----------------+---------------+---------------+---------------+ +| df.apply(…) | x 4 | x y | x 4 | +| df.agg(…) | y 6 | sum 4 6 | | ++-----------------+---------------+---------------+---------------+ ``` ```text -+----------------+---------------+---------------+---------------+ -| | 'rank' | ['rank'] | {'x': 'rank'} | -+----------------+---------------+---------------+---------------+ -| l.apply(…) | | x y | | -| l.agg(…) | x y | rank rank | x | -| l.transform(…) | a 1.0 1.0 | a 1.0 1.0 | a 1.0 | -| | b 2.0 2.0 | b 2.0 2.0 | b 2.0 | -+----------------+---------------+---------------+---------------+ ++-----------------+---------------+---------------+---------------+ +| | 'rank' | ['rank'] | {'x': 'rank'} | ++-----------------+---------------+---------------+---------------+ +| df.apply(…) | | x y | | +| df.agg(…) | x y | rank rank | x | +| df.transform(…) | a 1.0 1.0 | a 1.0 1.0 | a 1.0 | +| | b 2.0 2.0 | b 2.0 2.0 | b 2.0 | ++-----------------+---------------+---------------+---------------+ ``` * **All methods operate on columns by default. Pass `'axis=1'` to process the rows instead.** * **Fifth result's columns are indexed with a multi-index. This means we need a tuple of column keys to specify a column: `'.loc[row_key, (col_key_1, col_key_2)]'`.** diff --git a/index.html b/index.html index e450bed..48ccfc4 100644 --- a/index.html +++ b/index.html @@ -55,7 +55,7 @@
- +
@@ -2631,7 +2631,7 @@ plt.show() # Disp
  • Methods ffill(), interpolate(), fillna() and dropna() accept 'inplace=True'.
  • Last result has a multi-index. Use '<S>[key_1, key_2]' to get its values.
  • -

    DataFrame

    Table with labeled rows and columns.

    >>> l = pd.DataFrame([[1, 2], [3, 4]], index=['a', 'b'], columns=['x', 'y']); l
    +

    DataFrame

    Table with labeled rows and columns.

    >>> df = pd.DataFrame([[1, 2], [3, 4]], index=['a', 'b'], columns=['x', 'y']); df
        x  y
     a  1  2
     b  3  4
    @@ -2647,7 +2647,7 @@ b  3  4
     <DF>   = <DF>.loc[row_bools, col_bools]        # Or: <DF>.iloc[row_bools, col_bools]
     
    <S/DF> = <DF>[col_key/s]                       # Or: <DF>.<col_key>
    -<DF>   = <DF>[row_bools]                       # Keeps rows as specified by bools.
    +<DF>   = <DF>[<S_of_bools>]                    # Filters rows. For example `df[df.x > 1]`.
     <DF>   = <DF>[<DF_of_bools>]                   # Assigns NaN to items that are False in bools.
     
    <DF>   = <DF> > <el/S/DF>                      # Returns DF of bools. S is treated as a row.
    @@ -2660,62 +2660,62 @@ b  3  4
     
    <DF>   = <DF>.head/tail/sample(<int>)          # Returns first, last, or random n rows.
     <DF>   = <DF>.describe()                       # Describes columns. Also info(), corr(), shape.
    -<DF>   = <DF>.query('<query>')                 # Filters rows with e.g. 'col_1 == val_1 and …'.
    +<DF>   = <DF>.query('<query>')                 # Filters rows. For example `df.query('x > 1')`.
     
    <DF>.plot.line/area/bar/scatter(x=col_key, …)  # `y=col_key/s`. Also hist/box(by=col_key).
     plt.show()                                     # Displays the plot. Also plt.savefig(<path>).
     
    -

    DataFrame — Merge, Join, Concat:

    >>> r = pd.DataFrame([[4, 5], [6, 7]], index=['b', 'c'], columns=['y', 'z']); r
    +

    DataFrame — Merge, Join, Concat:

    >>> df_2 = pd.DataFrame([[4, 5], [6, 7]], index=['b', 'c'], columns=['y', 'z']); df_2
        y  z
     b  4  5
     c  6  7
     
    -
    ┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓
    -┃                        │    'outer''inner''left'   │       Description        ┃
    -┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
    -┃ l.merge(r, on='y',     │    x   y   z  │ x   y   z  │ x   y   z  │ Merges on column if 'on' ┃
    -┃            how=…)      │ 0  1   2   .  │ 3   4   51   2   .  │ or 'left/right_on' are   ┃
    -┃                        │ 1  3   4   5  │            │ 3   4   5  │ set, else on shared cols.┃
    -┃                        │ 2  .   6   7  │            │            │ Uses 'inner' by default. ┃
    -┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
    -┃ l.join(r, lsuffix='l', │    x yl yr  z │            │ x yl yr  z │ 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  ┃
    -┃                        │ 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 ┃
    -┃                        │ b  .   4   54      │            │ column. To add a row use ┃
    -┃                        │ c  .   6   76      │            │ pd.concat([l, DF([s])]). ┃
    -┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
    -┃ 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  ┃
    -┃                        │ c  .  .  6  7 │            │            │ treated as a column.     ┃
    -┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    +
    ┏━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
    +┃                       │    'outer''inner''left'   │       Description         ┃
    +┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨
    +┃ df.merge(df_2,        │    x   y   z  │ x   y   z  │ x   y   z  │ Merges on column if 'on'  ┃
    +┃          on='y',      │ 0  1   2   .  │ 3   4   51   2   .  │ or 'left/right_on' are    ┃
    +┃          how=…)       │ 1  3   4   5  │            │ 3   4   5  │ set, else on shared cols. ┃
    +┃                       │ 2  .   6   7  │            │            │ Uses 'inner' by default.  ┃
    +┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨
    +┃ df.join(df_2,         │    x yl yr  z │            │ x yl yr  z │ Merges on row keys.       ┃
    +┃         lsuffix='l',  │ a  1  2  .  . │ x yl yr  z │ 1  2  .  . │ Uses 'left' by default.   ┃
    +┃         rsuffix='r',  │ b  3  4  4  53  4  4  53  4  4  5 │ If r is a Series, it is   ┃
    +┃         how=…)        │ c  .  .  6  7 │            │            │ treated as a column.      ┃
    +┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨
    +┃ pd.concat([df, df_2], │    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  ┃
    +┃                       │ b  .   4   54      │            │ column. To add a row use  ┃
    +┃                       │ c  .   6   76      │            │ pd.concat([df, DF([s])]). ┃
    +┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨
    +┃ pd.concat([df, df_2], │    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   ┃
    +┃                       │ c  .  .  6  7 │            │            │ treated as a column.      ┃
    +┗━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
     

    DataFrame — Aggregate, Transform, Map:

    <S>  = <DF>.sum/max/mean/idxmax/all()          # Or: <DF>.apply/agg(lambda <S>: <el>)
     <DF> = <DF>.rank/diff/cumsum/ffill/interpo…()  # Or: <DF>.apply/agg/transform(lambda <S>: <S>)
     <DF> = <DF>.isna/fillna/isin([<el/coll>])      # Or: <DF>.applymap(lambda <el>: <el>)
     
    -
    ┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
    -┃                │     'sum'     │    ['sum']    │ {'x': 'sum'}  ┃
    -┠────────────────┼───────────────┼───────────────┼───────────────┨
    -┃ l.apply(…)     │      x  4     │        x  y   │     x  4      ┃
    -┃ l.agg(…)       │      y  6     │   sum  4  6   │               ┃
    -┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
    +
    ┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
    +┃                 │     'sum'     │    ['sum']    │ {'x': 'sum'}  ┃
    +┠─────────────────┼───────────────┼───────────────┼───────────────┨
    +┃ df.apply(…)     │      x  4     │        x  y   │     x  4      ┃
    +┃ df.agg(…)       │      y  6     │   sum  4  6   │               ┃
    +┗━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
     
    -┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
    -┃                │     'rank'    │    ['rank']   │ {'x': 'rank'} ┃
    -┠────────────────┼───────────────┼───────────────┼───────────────┨
    -┃ l.apply(…)     │               │       x    y  │               ┃
    -┃ l.agg(…)       │       x    y  │    rank rank  │         x     ┃
    -┃ l.transform(…) │  a  1.0  1.0  │  a  1.0  1.0  │    a  1.0     ┃
    -┃                │  b  2.0  2.0  │  b  2.0  2.0  │    b  2.0     ┃
    -┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
    +┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
    +┃                 │     'rank'    │    ['rank']   │ {'x': 'rank'} ┃
    +┠─────────────────┼───────────────┼───────────────┼───────────────┨
    +┃ df.apply(…)     │               │       x    y  │               ┃
    +┃ df.agg(…)       │       x    y  │    rank rank  │         x     ┃
    +┃ df.transform(…) │  a  1.0  1.0  │  a  1.0  1.0  │    a  1.0     ┃
    +┃                 │  b  2.0  2.0  │  b  2.0  2.0  │    b  2.0     ┃
    +┗━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
     
      @@ -2924,7 +2924,7 @@ $ deactivate # Deactivates the active diff --git a/parse.js b/parse.js index 16488b5..34b2886 100755 --- a/parse.js +++ b/parse.js @@ -599,56 +599,57 @@ const DIAGRAM_14_A = "| | 'rank' | ['rank'] | {'r': 'rank'} |"; const DIAGRAM_15_A = - '+------------------------+---------------+------------+------------+--------------------------+'; + '+-----------------------+---------------+------------+------------+---------------------------+'; const DIAGRAM_15_B = - "┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" + - "┃ │ 'outer' │ 'inner' │ 'left' │ Description ┃\n" + - "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + - "┃ l.merge(r, on='y', │ x y z │ x y z │ x y z │ Merges on column if 'on' ┃\n" + - "┃ how=…) │ 0 1 2 . │ 3 4 5 │ 1 2 . │ or 'left/right_on' are ┃\n" + - "┃ │ 1 3 4 5 │ │ 3 4 5 │ set, else on shared cols.┃\n" + - "┃ │ 2 . 6 7 │ │ │ Uses 'inner' by default. ┃\n" + - "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + - "┃ l.join(r, lsuffix='l', │ x yl yr z │ │ x yl yr z │ 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" + - "┃ │ 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" + - "┃ │ b . 4 5 │ 4 │ │ column. To add a row use ┃\n" + - "┃ │ c . 6 7 │ 6 │ │ pd.concat([l, DF([s])]). ┃\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" + - "┃ │ c . . 6 7 │ │ │ treated as a column. ┃\n" + - "┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"; + "┏━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" + + "┃ │ 'outer' │ 'inner' │ 'left' │ Description ┃\n" + + "┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨\n" + + "┃ df.merge(df_2, │ x y z │ x y z │ x y z │ Merges on column if 'on' ┃\n" + + "┃ on='y', │ 0 1 2 . │ 3 4 5 │ 1 2 . │ or 'left/right_on' are ┃\n" + + "┃ how=…) │ 1 3 4 5 │ │ 3 4 5 │ set, else on shared cols. ┃\n" + + "┃ │ 2 . 6 7 │ │ │ Uses 'inner' by default. ┃\n" + + "┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨\n" + + "┃ df.join(df_2, │ x yl yr z │ │ x yl yr z │ Merges on row keys. ┃\n" + + "┃ lsuffix='l', │ a 1 2 . . │ x yl yr z │ 1 2 . . │ Uses 'left' by default. ┃\n" + + "┃ rsuffix='r', │ b 3 4 4 5 │ 3 4 4 5 │ 3 4 4 5 │ If r is a Series, it is ┃\n" + + "┃ how=…) │ c . . 6 7 │ │ │ treated as a column. ┃\n" + + "┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨\n" + + "┃ pd.concat([df, df_2], │ 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" + + "┃ │ b . 4 5 │ 4 │ │ column. To add a row use ┃\n" + + "┃ │ c . 6 7 │ 6 │ │ pd.concat([df, DF([s])]). ┃\n" + + "┠───────────────────────┼───────────────┼────────────┼────────────┼───────────────────────────┨\n" + + "┃ pd.concat([df, df_2], │ 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" + + "┃ │ c . . 6 7 │ │ │ treated as a column. ┃\n" + + "┗━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"; + const DIAGRAM_16_A = - '| l.apply(…) | x 4 | x y | x 4 |'; + '| df.apply(…) | x 4 | x y | x 4 |'; const DIAGRAM_16_B = - "┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" + - "┃ │ 'sum' │ ['sum'] │ {'x': 'sum'} ┃\n" + - "┠────────────────┼───────────────┼───────────────┼───────────────┨\n" + - "┃ l.apply(…) │ x 4 │ x y │ x 4 ┃\n" + - "┃ l.agg(…) │ y 6 │ sum 4 6 │ ┃\n" + - "┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n" + + "┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" + + "┃ │ 'sum' │ ['sum'] │ {'x': 'sum'} ┃\n" + + "┠─────────────────┼───────────────┼───────────────┼───────────────┨\n" + + "┃ df.apply(…) │ x 4 │ x y │ x 4 ┃\n" + + "┃ df.agg(…) │ y 6 │ sum 4 6 │ ┃\n" + + "┗━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n" + "\n" + - "┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" + - "┃ │ 'rank' │ ['rank'] │ {'x': 'rank'} ┃\n" + - "┠────────────────┼───────────────┼───────────────┼───────────────┨\n" + - "┃ l.apply(…) │ │ x y │ ┃\n" + - "┃ l.agg(…) │ x y │ rank rank │ x ┃\n" + - "┃ l.transform(…) │ a 1.0 1.0 │ a 1.0 1.0 │ a 1.0 ┃\n" + - "┃ │ b 2.0 2.0 │ b 2.0 2.0 │ b 2.0 ┃\n" + - "┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; + "┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" + + "┃ │ 'rank' │ ['rank'] │ {'x': 'rank'} ┃\n" + + "┠─────────────────┼───────────────┼───────────────┼───────────────┨\n" + + "┃ df.apply(…) │ │ x y │ ┃\n" + + "┃ df.agg(…) │ x y │ rank rank │ x ┃\n" + + "┃ df.transform(…) │ a 1.0 1.0 │ a 1.0 1.0 │ a 1.0 ┃\n" + + "┃ │ b 2.0 2.0 │ b 2.0 2.0 │ b 2.0 ┃\n" + + "┗━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; const DIAGRAM_17_A = - "| | 'rank' | ['rank'] | {'x': 'rank'} |"; + "| | 'rank' | ['rank'] | {'x': 'rank'} |"; const DIAGRAM_18_A = '| gb.agg(…) | x y | | x y | |'; @@ -897,7 +898,7 @@ function insertPageBreakBefore(an_id) { } function fixPandasDiagram() { - const diagram_15 = '┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓'; + const diagram_15 = '┏━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━┓'; $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(and)").after("and"); $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(as)").after("as"); $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(is)").after("is"); @@ -905,6 +906,10 @@ function fixPandasDiagram() { $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(or)").after("or"); $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(else)").after("else"); $(`code:contains(${diagram_15})`).find(".hljs-keyword").remove(); + $(`code:contains(${diagram_15})`).find(".hljs-string:contains(\'left/right_on\')").after("\'left/right_on\'"); + $(`code:contains(${diagram_15})`).find(".hljs-string:contains(\'left/right_on\')").remove(); + $(`code:contains(${diagram_15})`).find(".hljs-string:contains('on')").after("'on'"); + $(`code:contains(${diagram_15})`).find(".hljs-string:contains('on')").remove(); } function removePlotImages() {