|
6 | 6 | #+AUTHOR: Derek Devnich |
7 | 7 |
|
8 | 8 | * COMMENT Notes |
| 9 | +** Teaching notes from Fall 2026 UC Carpentry |
| 10 | +1. Terminal install is a problem |
| 11 | + - Need easy backup |
| 12 | +2. Get data from Python? |
| 13 | + - http fetch |
| 14 | + - short url for zip |
| 15 | +3. Review SQL-like materials in Week 2 |
| 16 | +4. Excel import: https://openpyxl.readthedocs.io/en/stable/ |
| 17 | +5. https://python-graph-gallery.com |
| 18 | +6. https://github.com/trevismd/statannotations |
| 19 | + |
9 | 20 | ** Drops down to NumPy for numeric calculations, obviating any Pandas issues |
10 | 21 | #+BEGIN_SRC python |
11 | 22 | def zScoreCalc (filename, index_colum_name = None): |
@@ -1281,23 +1292,31 @@ This is most common way to get data |
1281 | 1292 | print(subset.max(axis=None)) |
1282 | 1293 | #+END_SRC |
1283 | 1294 |
|
1284 | | -***( Optional) Get x/y labels for the cell that matches a criterion |
1285 | | -#+begin_src python |
1286 | | -# Which values match the criterion? |
1287 | | -subset == subset.max().max() |
| 1295 | +*** (Optional) How to get the x and y labels for the cell that matches a criterion |
| 1296 | +1. Doing it the hard way |
| 1297 | + #+begin_src python |
| 1298 | + # Which values match the criterion? |
| 1299 | + subset == subset.max().max() |
| 1300 | + |
| 1301 | + # Return value at position, code all other cells as NA |
| 1302 | + val = subset[subset == subset.max().max()] |
1288 | 1303 |
|
1289 | | -# Return value at position, code all other cells as NA |
1290 | | -val = subset[subset == subset.max().max()] |
| 1304 | + # Drop rows where all values are NA, then drop columns where values are NA |
| 1305 | + val.dropna(how="all").dropna(axis=1) |
1291 | 1306 |
|
1292 | | -# Drop rows where all values are NA, then drop columns where values are NA |
1293 | | -val.dropna(how="all").dropna(axis=1) |
| 1307 | + # Putting it all together: Get index label and column label for last remaining cell |
| 1308 | + names = val.dropna(how="all").dropna(axis=1) |
1294 | 1309 |
|
1295 | | -# Putting it all together: Get index label and column label for last remaining cell |
1296 | | -names = val.dropna(how="all").dropna(axis=1) |
| 1310 | + print(names.index[0]) |
| 1311 | + print(names.columns[0]) |
| 1312 | + #+end_src |
1297 | 1313 |
|
1298 | | -print(names.index[0]) |
1299 | | -print(names.columns[0]) |
1300 | | -#+end_src |
| 1314 | +2. Frequently there will be a built-in method that solves the same problem |
| 1315 | + #+begin_src python |
| 1316 | + df.idxmax() |
| 1317 | + df.unique() |
| 1318 | + df.nunique() |
| 1319 | + #+end_src |
1301 | 1320 |
|
1302 | 1321 | *** (Optional) Filter on label properties |
1303 | 1322 | 1. ~.filter()~ always returns the same type as the original item, whereas ~.loc~ and ~.iloc~ might return a data frame or a series. |
|
0 commit comments