Skip to content

Instantly share code, notes, and snippets.

ehborisov / Spark Dataframe Cheat
Last active October 12, 2020 07:01 — forked from AlessandroChecco/Spark Dataframe Cheat
Cheat sheet for Spark Dataframes (using Python)
# A simple cheat sheet of Spark Dataframe syntax
# Current for Spark 1.6.1
# import statements
#from pyspark.sql import SQLContext
#from pyspark.sql.types import *
#from pyspark.sql.functions import *
from pyspark.sql import functions as F
#SparkContext available as sc, HiveContext available as sqlContext.
# BST is a linked data structure in which each node is an object.
# In addition to a key and satellite data, each node contains attributes left, right, and p
# that point to the nodes corresponding to its left child and its parent.
# BST property
# x is a node in BST if y is any node in a left subtree than y.key <= x.key if y is any node in a right subtree
# than y.key >= x.key
class Node(object):
Rooted tree with unbounded branching, left child - right sibling representation backed by 4 arrays.
class UnboundedTree(object):
def __init__(self):
self.root = 0 = [
class MinHeap(object):
def __init__(self): = []
def add(self, val):
def get_min(self):
# Linked lists are data structures made of chained elements connected either with one or with two others.
from collections import namedtuple
# Singly linked list node (immutable)
_Node = namedtuple('Node', ['value', 'next'])
# or mutable
def parentheses_combinations_brute_force_1(n):
ans = []
def generate_all(candidate):
if len(candidate) == 2 * n:
if is_valid(candidate):
def solveNQueens(n):
Returns all possible combinations of N queens placement.
:type n: int
:rtype: List[List[str]]
board = [['.'] * n for _ in range(n)]
solutions = []
import sys
import collections
Node = collections.namedtuple('Node', ['value', 'next'])
def check_palindrome_n2(head_node):
seen = []
if not
return True
package io.qameta.htmlelements.handler;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
package io.qameta.htmlelements.handler;
import io.qameta.htmlelements.context.Context;
import io.qameta.htmlelements.context.Store;
import io.qameta.htmlelements.exception.MethodInvocationException;
import io.qameta.htmlelements.exception.NotImplementedException;
import io.qameta.htmlelements.extension.TargetModifier;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;