A walk through Python data structures
What are data structures?
A walk through Python data structures
What are data structures?
To perform computations, data has to be stored in a certain format. These can take various forms in Python.
What types of data structures are there?
There are a whole wide range of data structures available. They range from specific data types — e.g. integers, strings to data structures such as lists and arrays.
The most common data structures that will need to be used for quantitative stuff are unsurprisingly:
Integers
Floats
Decimal
For those from a programming background, Python is dynamically typed. This means that there is no need to declare a specific for each variable that is used. Python will automatically assign.
> myInteger = 1
> type(myInteger)
int> myFloat = 1.0
> type(myFloat)
floatThe other data types that one must know when using Python are:
tuples — these can be declared with tuple, or by placing items inside brackets (a, b, c)
lists — these can be declared similarly with list, or placing items inside square brackets [a,b,c]
dictionaries — similarly with dict, or with mustachios {‘One’:a, ‘Two’:b, ‘Three’:c}
sets — collection of unique items, just convert by declaring a list as a set
Details and demos on each of these data structures are available in the Jupyter notebook here


