Python for Data Processing and Plo3ng Han-Wei Shen The Ohio State University (with help from Jonathan Woodring at Los Alamos NaConal Laboratory)
What is Python? • Fast code development and test • A dynamically typed language – You do not need to declare the type of a variable • Syntax is very much C-like • A huge number of packages for doing almost everything (numpy, scipy, matplotlib, …) • AutomaCc memory management • FuncCons can be passed around as arguments • Can bind to C code easily for speed (from Jonathan Woodring, Los Alamos NL)
Variable Assignment
More Assignment
Lists
Slicing Lists
Slicing Lists
IteraCng Lists with Loops
IteraCng Lists with Loops
If-Then-Else
Tuples are Immutable
DicConaries
FuncCon DefiniCons
File I/O
NumPy The most popular package for scienCfic compuCng • – Efficient N-dimensional arrays – Useful for linear algebra, data transformaCon etc. Get Numpy from hYp://www.scipy.org •
NumPy The most popular package for scienCfic compuCng • – Efficient N-dimensional arrays – Useful for linear algebra, data transformaCon etc. Get Numpy from hYp://www.scipy.org •
NumPy Slicing
NumPy Array Reshaping
NumPy Array BroadcasCng
NumPy Linear Algebra
NumPy I/O
Matplotlib Python 2D plo3ng package that produces publicaCon quality figures • Get it from hYp://matplotlib.org •
Line Graphs
Images
Histograms
Recommend
More recommend