I know pandas is built on NumPy, and my class examples also always include import NumPy first. I'm just not sure if this is a required step or a "just in case" type situation.
It's not necessary to import numpy
before importing pandas. numpy
is implicitly imported by and internally used within the pandas
module. For example:
In [1]: import pandas as pd
In [2]: s = pd.Series(range(10))
In [3]: s
Out[3]:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
dtype: int64
In [4]: s.mean()
Out[4]: np.float64(4.5)
The reason that it is often imported along with pandas is that you often will create an array using numpy which is then passed to pandas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With