Skip to content

Instantly share code, notes, and snippets.

Spark - using Pyspark functions

usually prefer using Spark SQL

but sometimes makes sense to use pyspark functions

select where like

@jimathyp
jimathyp / black-python-formatter.md
Created August 9, 2022 23:58
'Black' python formatter usage notes

"Black" - A Python Formatter

Black will format your code. It can do it automatically on save, or when required.

Black is opinionated - this means it has basically one and only one way that the Python code will be formatted. There is almost no configuraiton.

One major opinion it enforces is the use of double quotes in place of single quotes.

This can be a major change to an existing project.

Installing pip packages globally

https://github.com/pypa/pipx

Certain tools you may wish to use throughout your virtual environments.

One way to achieve this is to install the package 'globally', ie. not in a virtual env.

However more tools - more risk of dependency issues.

@jimathyp
jimathyp / python-decorator.md
Last active August 25, 2022 23:41
notes for teaching decorators

Python decorators

In Python a function is an object. It can be assigned to a variable, and calling a function is a separate action.

def some_func():
  print("hi")
  
a = some_func

Spark SQL

  • Constants
  • Series generation
  • Reading JSON
  • Schemas
  • Day of week

VS Code Shortcuts

Show shortcuts - Ctrl K, Ctrl S

Duplicate workspace - Ctrl Shift P

Open file in new window - Ctrl K, release, O

General Excel tips

Enter a new line within a cell = Alt + Enter