Skip to content

Instantly share code, notes, and snippets.

View fomightez's full-sized avatar

Wayne's Bioinformatics Code Portal fomightez

View GitHub Profile
@fomightez
fomightez / useful_python_snippets.py
Last active November 4, 2025 19:09
Useful Python snippets
# 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/
@fomightez
fomightez / useful_notebook_snippets
Last active November 4, 2025 19:06
Useful snippets for Jupyter notebooks
# 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)
@fomightez
fomightez / useful_pandas_snippets.py
Last active September 11, 2025 18:25 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# 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/)
@fomightez
fomightez / Pandas dataframe to Pandas Styler Object to MS WORD via HTML.ipynb
Last active August 20, 2025 18:10
Pandas dataframe to Pandas Styler Object to Microsoft WORD via HTML
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / Tables_and_Styling_and_HTML_and_Pandas.ipynb
Last active August 20, 2025 17:30
Tables and Styling and HTML & Pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / README.md
Last active August 13, 2025 16:31
3D surface plots working in SageMath 10.7 kernel in Jupyter August 2025

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.




@fomightez
fomightez / useful_ipython_or_commandline_to_python_snippets.py
Last active August 12, 2025 12:30
Useful snippets and examples for when converting command line commands from Jupyter/IPython back to Pure Python
#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.
@fomightez
fomightez / README.md
Last active July 26, 2025 02:09 — forked from jtpio/README.md
JupyterLab 4.3 on Binder

JupyterLab 4.3 with Python 3.12 on Binder

Binder

@fomightez
fomightez / README.md
Last active July 26, 2025 02:04
JupyterLab current on Binder with awscli and zstd