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_pandas_snippets.py
Last active April 19, 2024 18:25 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
df['Column Name'].unique()
# 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/)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / Guide to distinguishing Jupyter interfaces early 2024.md
Last active April 8, 2024 21:17
Guide to distinguishing Jupyter interfaces early 2024

Quickly Navigating the tech of the Jupyter ecosystem post-2023

The Jupyter ecosystem got more complex in 2023. Want more background, see the second half of my answer here that references resources detailing how the Jupyter ecosystem changed a lot in 2023 with Jupyter Notebook 7+ now being built on the same components as JupyterLab.

The upshot of this is now it can be hard to tell what you are using for writing and running Jupyter notebook .ipynb files. However, knowing this can be important when you want to do something like display an interactive matplotlib-based plot or make a an animation.

One key indicator to distinguishing the flavor of classic style vs. modern:

KEY TIP: Older style has a 'Cell' menu along the File menubar.

Does the menubar the starts with 'File' include 'Cell'?

@fomightez
fomightez / a_text_to_dataframe.md
Last active April 5, 2024 04:03
Text lists ===> Python Pandas dataframe

(Note that if using this approach for pasting dataframes into StackOverflow, use CSV and not TSV, see here.)

Small text lists with column headers ==> Pandas dataframes

Without need for a separate file; although list could could be in separate file, and then just not use StringIO. Handy for toy code and keeping examples compact and as one file.

IMPORTANT THING IS TO HAVE import SOURCE MATCH VERSION OF PYTHON, check with import sys;print (sys.version). Or use provided approach compatible with both Python 2 and 3.

@fomightez
fomightez / mainFROMJupyterLab.ipynb
Created April 3, 2024 17:18
Further investigating SO https://stackoverflow.com/q/78267508/8508004 Seeing if JupyterLab results in less useable on nbviewer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / MoHassan01main.ipynb
Created April 3, 2024 16:14
Further investigating SO https://stackoverflow.com/q/78267508/8508004 THIS TIME ALL THE CONTENT OF MAIN
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / MoHassan01main.ipynb
Created April 3, 2024 16:13
Further investigating SO https://stackoverflow.com/q/78267508/8508004 THIS TIME ALL OF MAIN TO ATTEMPT
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fomightez
fomightez / MoHassan01main3with2plots.ipynb
Created April 3, 2024 15:30
Further investigating SO https://stackoverflow.com/q/78267508/8508004 THIS TIME TWO OF THE MANY PLOTS
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.