Lesson 3 of 13 · 2 min
Series
import pandas as pd # Create Series from a list s = pd.Series([1, 3, 5, 7, 9, 11, 13]) print(s) # Output: # 0 1 # 1 3 # 2 5 # 3 7 # 4 9 # 5 11 # 6 13 # dtype: int64 print(s.shape) # Output: (7,) print(s.dtypes) # Output: int64 print(s.head(3)) # Output: 0 1 / 1 3 / 2 5 print(s.mean()) # Output: 7.0 print(s.median()) # Output: 7.0 print(s.mode()) # Output: 0 1 / ... (no mode since all unique)
import numpy as np import pandas as pd # Series from numpy arange arr = np.arange(1, 20, 2) # [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] s = pd.Series(arr) print(s.mean()) # Output: 10.0 print(s.median()) # Output: 10.0
