diff --git a/README.md b/README.md index 8f0557e..3f77cb3 100644 --- a/README.md +++ b/README.md @@ -2693,6 +2693,7 @@ import numpy as np <1d/2d_a> = <2d_array>[<2d/1d_bools>] # 1d_bools must have size of a column. ``` * **Indexes should not be tuples because Python converts `'obj[i, j]'` to `'obj[(i, j)]'`!** +* **`':'` returns a slice of all dimension's indexes. Omitted dimensions default to `':'`.** * **Any value that is broadcastable to the indexed shape can be assigned to the selection.** ### Broadcasting @@ -2738,9 +2739,7 @@ right = [[0.1, 0.6, 0.8], # Shape: (3, 3) <- ! [[ 0. , 0.5, 0.7], [ 0.5, 0. , 0.2], [ 0.7, 0.2, 0. ]] ->>> i = np.arange(3) -[0, 1, 2] ->>> distances[i, i] = np.inf +>>> distances[range(3), range(3)] = np.inf [[ inf, 0.5, 0.7], [ 0.5, inf, 0.2], [ 0.7, 0.2, inf]] @@ -2765,11 +2764,11 @@ from PIL import Image, ImageFilter, ImageEnhance ``` ```python - = .getpixel((x, y)) # Returns a pixel. -.putpixel((x, y), ) # Writes a pixel to the image. - = .getdata() # Returns a flattened view of the pixels. -.putdata() # Writes a flattened sequence of pixels. -.paste(, (x, y)) # Writes passed image to the image. + = .getpixel((x, y)) # Returns pixel's color. +.putpixel((x, y), ) # Changes pixel's color. + = .getdata() # Returns a flattened view of all pixels. +.putdata() # Updates pixels with a copy of the sequence. +.paste(, (x, y)) # Draws passed image at specified location. ``` ```python @@ -3344,9 +3343,9 @@ plt.show() # Displays the plot. Also plt.sav ```python = pd.read_json/html('') # Run `$ pip3 install beautifulsoup4 lxml`. - = pd.read_csv/pickle/excel('') # Use `sheet_name=None` to get all Excel sheets. + = pd.read_csv('') # Also `names=, parse_dates=False`. + = pd.read_pickle/excel('') # Use `sheet_name=None` to get all Excel sheets. = pd.read_sql('', ) # SQLite3/SQLAlchemy connection (see #SQLite). - = pd.read_clipboard() # Reads a copied table from the clipboard. ``` ```python @@ -3371,6 +3370,7 @@ c 7 8 6 = .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. + = .size() # A Sr of group sizes. Keys are group "names". ``` #### GroupBy — Aggregate, Transform, Map: diff --git a/index.html b/index.html index 73a8ad3..5c7198c 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2198,6 +2198,7 @@ $ snakeviz test.prof
  • Indexes should not be tuples because Python converts 'obj[i, j]' to 'obj[(i, j)]'!
  • +
  • ':' returns a slice of all dimension's indexes. Omitted dimensions default to ':'.
  • Any value that is broadcastable to the indexed shape can be assigned to the selection.

Broadcasting

Set of rules by which NumPy functions operate on arrays of different sizes and/or dimensions.

left  = [[0.1], [0.6], [0.8]]                           # Shape: (3, 1)
@@ -2232,9 +2233,7 @@ right = [[0.1,  0.60. ,  0.5,  0.7],
  [ 0.5,  0. ,  0.2],
  [ 0.7,  0.2,  0. ]]
->>> i = np.arange(3)
-[0, 1, 2]
->>> distances[i, i] = np.inf
+>>> distances[range(3), range(3)] = np.inf
 [[ inf,  0.5,  0.7],
  [ 0.5,  inf,  0.2],
  [ 0.7,  0.2,  inf]]
@@ -2253,11 +2252,11 @@ right = [[0.1,  0.6# Selects format based on the path extension.
 <Image>.show()                                    # Opens image in the default preview app.
 
-
<int/tuple> = <Image>.getpixel((x, y))            # Returns a pixel.
-<Image>.putpixel((x, y), <int/tuple>)             # Writes a pixel to the image.
-<ImagingCore> = <Image>.getdata()                 # Returns a flattened view of the pixels.
-<Image>.putdata(<list/ImagingCore>)               # Writes a flattened sequence of pixels.
-<Image>.paste(<Image>, (x, y))                    # Writes passed image to the image.
+
<int/tuple> = <Image>.getpixel((x, y))            # Returns pixel's color.
+<Image>.putpixel((x, y), <int/tuple>)             # Changes pixel's color.
+<ImagingCore> = <Image>.getdata()                 # Returns a flattened view of all pixels.
+<Image>.putdata(<list/ImagingCore>)               # Updates pixels with a copy of the sequence.
+<Image>.paste(<Image>, (x, y))                    # Draws passed image at specified location.
 
<Image> = <Image>.filter(<Filter>)                # `<Filter> = ImageFilter.<name>([<args>])`
 <Image> = <Enhance>.enhance(<float>)              # `<Enhance> = ImageEnhance.<name>(<Image>)`
@@ -2727,9 +2726,9 @@ plt.show()                                     # Disp
 
<DF> = pd.read_json/html('<str/path/url>')     # Run `$ pip3 install beautifulsoup4 lxml`.
-<DF> = pd.read_csv/pickle/excel('<path/url>')  # Use `sheet_name=None` to get all Excel sheets.
+<DF> = pd.read_csv('<path/url>')               # Also `names=<list>, parse_dates=False`.
+<DF> = pd.read_pickle/excel('<path/url>')      # Use `sheet_name=None` to get all Excel sheets.
 <DF> = pd.read_sql('<table/query>', <conn.>)   # SQLite3/SQLAlchemy connection (see #SQLite).
-<DF> = pd.read_clipboard()                     # Reads a copied table from the clipboard.
 
<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>]).
@@ -2747,6 +2746,7 @@ c  7  8  <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.
+<Sr> = <GB>.size()                             # A Sr of group sizes. Keys are group "names".
 

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>)
@@ -2925,7 +2925,7 @@ $ deactivate                  # Deactivates the activ
  
 
   
- +