Understanding NumPy basics
Another library that's useful for dealing with data is NumPy (numpy
). The name stands for "Numeric Python," and it has many tools for advanced mathematical calculations and the representation of numeric data. NumPy is used by other Python packages for computations, such as the scikit-learn machine learning library. In fact, pandas is built on top of NumPy. With NumPy, we'll learn:
- How data is represented in NumPy
- How to use some of NumPy's mathematical function and features
- How NumPy relates to and works with pandas
The pandas library actually stores its data as NumPy arrays. An array is similar to a list, but has more capabilities and properties. We can extract an array from our DataFrame like so:
close_array = btc_df['close'].values
This gives us a NumPy array:
array([ 93.033 , 103.999 , 118.22935407, ...,
17211.69580098, 17171. , 17686.840768 ...