Skip to main content
Beta
This lesson is in the beta phase, which means that it is ready for teaching by instructors outside of the original author team.
Key Points
- Assign values to variables using
=
- Generate lists using square brackets
[]
- Use indexes inside
[], starting at 0, to select
characters from strings and items from lists
- Use
for to loop through items in iterable objects
- Make conditional expressions using
==, !=,
>, <, >= and
<=
- Use
f'{}' to embed formatted variables inside
strings
- Avoid use of generative AI for this course
- 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
-
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
- CSV data is loaded using the
read_csv() function to
create a pandas DataFrame object
- The
describe() function gives a quick analysis of the
DataFrame
-
loc[<index>,<column>] indexes the DataFrame
by the index and column labels
-
iloc[<index>,<column>] indexes the
DataFrame using numerical indices
- The data can be sliced by providing index and/or column indices as
ranges or lists of values
- The built-in
plot() function can be used to plot the
data using the matplotlib library
- user interfaces
- Streamlit