4 Working with collections in Julia
This chapter covers
- Working with arrays
- Using dictionaries to handle key–value mappings
- Handling immutable collection types: tuples and named tuples
In chapters 2 and 3 you learned basic elements of the Julia language. We have mostly used scalar types (like numbers) in all the examples. However, in data science you will typically work with data collections, that is, groupings of some variable number of data items. One collection type we have already introduced in chapter 2 is a vector.
In this chapter you will learn how to use several fundamental collections that are most used in practical scenarios: arrays, dictionaries, tuples, and named tuples.
4.1 Working with arrays
In this section you will learn the basics of working with arrays in Julia: their creation, indexing into arrays and most common operations you can expect to perform when working with arrays. Arrays are commonly used collections in data science. Most of the machine learning algorithms expect data stored in arrays as their inputs. In Julia, as opposed to, for example, Python, arrays are part of the language specification so they are equipped with a convenient syntax, there is only one set of rules for working with them you will need to learn, and they are fast.