Python Basics Recap
|
variables
lists
indexing
loops
conditionals
|
Dictionaries
|
JSON is simple
Dictionaries are defined using key :value pairs
Dictionaries can be nested, and mixed with lists
Web API’s can be accessed using the requests library
|
Numpy and Matplotlib Essential
|
NumPy arrays are not matrix objects
Array masks can be created using conditional statements
NumPy arrays can be masked to hide data you don’t want to include in an analysis
NumPy libraries are available for reading a lot of different file formats
|
Software Package Management
|
conda virtual environments are useful for installing programs with differing requirements
conda config --add channels <channel> adds a new channel to your list of sources
conda search <package> will find all available versions of a package in your list of sources
conda create -n <env> <package(s)> can be used to create a virtual environment from a list of packages
conda install -n <env> <pacakge(s)> installs packages in a pre-existing environment
conda activate <env> activates the named environment, giving access to the software installed there
conda deactivate deactivates the current environment
conda env export --from-history > <file.yml> creates a portable record of your current environment
conda env create --file <file.yml> <env> creates a new environment from an environment file
|
Defensive Programming
|
try-except structures are useful for catching errors as they occur
assert structures are useful for forcing errors early, to avoid wasted effort
|
Units and Quantities
|
astropy.units library provides unit support
Quantity objects are created by multiplying values by the desired units
The .to() function can be used to convert units
The .decompose() function can be used to convert to the base (irreducible) units
Equivalences can be found using the .find_equivalent_units() function
Specific equivalence libraries can be defined using the equivalences= keyword
Import quantity-support from astropy.visualization to integrate units with matplotlib for data plotting
The pint library provides similar unit support, but is better for working with temperature increments
|
Pandas Essential
|
CSV data is loaded using the load_csv() function
The describe() function gives a quick analysis of the data
loc[<index>,<column>] indexes the data array by the index and column labels
iloc[<index>,<column>] indexes the data array using numerical indicies
The data can be sliced by providing index and/or column indicies as ranges or lists of values
The built-in plot() function can be used to plot the data using the matplotlib library
|