Calculating summaries by group with NumPy arrays
We will work again with the COVID-19 case daily data and the Brazil land temperature data.
How to do it…
We copy DataFrame values to a NumPy array. We then navigate over the array, calculating totals by group and checking for unexpected changes in values:
numpy, and load the Covid and land temperature data:
>>> import pandas as pd >>> import numpy as np >>> coviddaily = pd.read_csv("data/coviddaily720.csv", parse_dates=["casedate"]) >>> ltbrazil = pd.read_csv("data/ltbrazil.csv")
- Create a list of locations:
>>> loclist = coviddaily.location.unique().tolist()
- Use a NumPy array to calculate sums by location.
Create a NumPy array...