August 2019
Beginner
482 pages
12h 56m
English
Now, having a dataframe in place, let's answer some simple questions; for example, which battles took the most lives on both sides? To answer that, we need to add two columns, sort the dataframe by the result, from larger to smaller, and print out first N records. Let's do it:
>>> kill_cols = ['allies killed', 'axis killed']>>> data['killed total'] = data[kill_cols].sum(1)>>> data['killed total'].sort_values(ascending=False).head(3)>>> name Battle of Stalingrad 1997993.0 Battle of Moscow 1203428.0 Battle of Kiev (1941) 661958.0 Name: killed total, dtype: float64
The next question might be on the typical number of casualties for each battle. Before we calculate the statistics, we have to filter rows with unknown (NaN) ...
Read now
Unlock full access