Cheatography
https://cheatography.com
Focus on scripting for data. Reference to what I personally forget syntax on.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Syntax, Oh How You've Changed
Comments |
Case-sensitive |
' versus " |
Tomato, Toma-to |
Escape |
\, 'Admiral Hopper\'s Great!'
|
Test |
|
Catch Errors |
|
Loops |
for hero in sheros:
, while cops > 0:
|
Functions |
def inclusion(axis_of_oppression, status=True):
|
Strings, Please Don't Make Spaghetti
|
Ada is in the list X times |
.replace('het','queer')
|
history to future |
|
whitespace, not your t-shirt |
"My {0} used {1}.".format("Mom","punch cards")
|
List, I will finish you
Order |
.sort(key=len, reverse=True)
Z to A. len
is f(x) .sorted()
for any iterable |
Subset |
kids[1:3]
get index 1 & 2 (Slice) |
List Math |
mylist + mylist
== mylist * 2
|
Contains? |
'asexual' in sexual_orientations
|
From the end |
|
CRUD |
.append()
, __, __, .pop()
|
Nest |
family[0][0]
get Drag Grandchild |
Dictionaries, Let's Get Real
>>> words = {'white supremacy': 'systemic racism',
'patriarchy': 'sexism'}
>>> words.keys()
dict_keys(['white supremacy', 'patriarchy'])
>>> words.values()
dict_values(['systemic racism', 'sexism'])
|
Compare & Contrast, A Non-Essay
Even? |
|
Contains Element |
Contains Sub-string |
|
|
Data Libraries, Dewey to my CSVs
import numpy as np |
import pandas as pd |
|
|
|