This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
tutorials:python_quick_reference [2021/05/01 16:26] marcus.williams [Setting and filling data] |
tutorials:python_quick_reference [2021/05/13 16:03] marcus.williams [Python Debugger (PDB)] |
||
---|---|---|---|
Line 172: | Line 172: | ||
df.reset_index() | df.reset_index() | ||
</code> | </code> | ||
+ | |||
+ | Remove an unwanted level | ||
+ | <code> | ||
+ | df.columns = df.columns.get_level_values('CEUDEndUse_res') | ||
+ | </code> | ||
+ | |||
===== Dropping/deleting data ===== | ===== Dropping/deleting data ===== | ||
Line 414: | Line 420: | ||
git pull origin master | git pull origin master | ||
</code> | </code> | ||
+ | |||
+ | ===== Handy Matrix & Vector Operations ===== | ||
+ | |||
+ | **shares / norm** | ||
+ | |||
+ | each row sums to 1 | ||
+ | <code> | ||
+ | df_shr = df_quantity.div(df_quantity.sum(axis='columns'), axis='index')) | ||
+ | </code> | ||
+ | |||
+ | each column sums to 1 | ||
+ | <code> | ||
+ | df_shr = df_quantity.div(df_quantity.sum(axis='index'), axis='columns')) | ||
+ | </code> | ||
+ | |||
+ | ===== Jupyter Notebook Markdown Tricks ===== | ||
+ | Links | ||
+ | <code> | ||
+ | [Github](http://github.com) | ||
+ | </code> | ||
+ | |||
+ | |||
+ | Embed an image | ||
+ | <code> | ||
+ | ![title](img/S_res_1.png) | ||
+ | </code> | ||
+ | |||
+ | ===== Python Debugger (PDB) ===== | ||
+ | [[https://docs.python.org/3/library/pdb.html|ref]] | ||
+ | |||
+ | <code> | ||
+ | import pdb; pdb.set_trace() | ||
+ | </code> | ||
+ | |||
+ | ''n'' for next line; ''c'' to continue; ''s'' for step; ''exit'' for exit | ||
===== Other functions ===== | ===== Other functions ===== | ||
==== A ==== | ==== A ==== |