...

/

Similarities in pandas and NumPy

Similarities in pandas and NumPy

Learn about the similarities between pandas and NumPy.

We'll cover the following...

Similar to NumPy

The Series object behaves similarly to a NumPy array. As shown below, both types respond to index operations:

Press + to interact
import numpy as np
import pandas as pd
songs3 = pd.Series([145, 142, 38, 13], name='counts', index=['Paul', 'John', 'George', 'Ringo'])
numpy_ser = np.array([145, 142, 38, 13])
print(songs3[1])
print(numpy_ser[1])

They both have these methods in common:

Press + to interact
print(songs3.mean())
print(numpy_ser.mean())

They also both have a notion of a boolean array. A boolean array is a Series with the same index as the Series we’re working with and has boolean values. It can be used as a mask to filter out items. Normal Python lists ...