Many systems in science and engineering are nonlinear and high-dimensional, and in practice we often have only time-series data rather than governing equations. The Koopman operator describes how functions of the state, called observables, evolve in time. This evolution is linear even when the dynamics are nonlinear, which makes it possible to analyze nonlinear systems from data with tools from numerical linear algebra and spectral theory. In this talk, I will give an introduction to Koopman operator theory and its data-driven approximations, including dynamic mode decomposition (DMD), its extensions and recent neural network approaches. Since the Koopman operator is infinite-dimensional, I will also discuss when the computed spectral information can be trusted and how this can be checked from data. I will then extend these ideas to stochastic systems, where the spectrum captures slow transitions and long-time behavior. Examples of application of the Koopman operator from neuroscience, El Niño forecasting and the sampling of probability distributions will be used to illustrate the methods.