Pertinent Stackoverflow post with SageMath code that plots 3D surfaces using SageMath 10.7 kernel in Jupyter at present:
https://stackoverflow.com/q/79733626/8508004
See my comments there on how to run the demonstration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # These are meant to work in both Python 2 and 3, except where noted. | |
| # See my useful_pandas_snippets.py for those related to dataframes (such as pickling/`df.to_pickle(save_as)`) | |
| # https://gist.github.com/fomightez/ef57387b5d23106fabd4e02dab6819b4 | |
| # also see https://gist.github.com/fomightez/324b7446dc08e56c83fa2d7af2b89a33 for examples of my | |
| # frequently used Python functions and slight variations for more expanded, modular structures. | |
| #argparse | |
| # good snippet collection at https://mkaz.tech/code/python-argparse-cookbook/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Use `%%capture` to hush 'noisy' stdout and stderr streams, but still combine with getting `%%time` after | |
| %%capture out_stream | |
| %%time | |
| ---rest of a cell that does something with LOTS of output-- | |
| #In cell after, put following to get time of completion from that: | |
| #time it took to run cell above | |
| for x in out_stream.stdout.split("\n")[-3:]: | |
| print(x) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # List unique values in a DataFrame column | |
| df['Column Name'].unique() # Note, `NaN` is included as a unique value. If you just want the number, use `nunique()` which stands | |
| # for 'number of unique values'; By default, it excludes `NaN`. `.nunique(dropna=False)` will include `NaN` in the count of unique values. | |
| # To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation. | |
| df.height | |
| df['height'] | |
| # are same thing!!! (from http://www.stephaniehicks.com/learnPython/pages/pandas.html | |
| # -or- | |
| # http://www.datacarpentry.org/python-ecology-lesson/02-index-slice-subset/) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Useful examples for when converting command line commands from Jupyter/IPython back to Pure Python | |
| # This is party for when need to speed up a `.ipy` script running. It will run much faster as `.py` than as `.ipy` if there | |
| # are a lot of calls to command line / shell commands because saves time by not spawning new shell instance for | |
| # each. (`.ipy` version great for quicker development and proto-typing but `.py` MUCH FASTER for running.) | |
| # The Python versions also have the advantage that you can use them inside functions (I think) because don't have problem like | |
| # with `!cp fn unsanitized_{fn}`or `%store` where actually run in global namespace which cannot see Python variable `fn` | |
| # local to the function. | |
| # RELATED NOTE: You can use the IPython `history` (via the "hist command (with -n to remove line numbers)") to | |
| # help convert `.ipy` code or Jupyter code with exclamation marks and shell commands BACK TO PYTHON, see | |
| # https://stackoverflow.com/a/1040640/8508004 (especially also see the comment by Mic |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
To work with LOGAN Search data, see slide 35 of Rayan Chikhi | Project Logan Assembling all public sequencing data | CGSI 2024 (around 20.32 minute mark), need awscli and zst installed
NewerOlder