# Import modules import pandas as pd # Set ipython's max row display pd.set_option('display.max_row', 1000) # Set iPython's max column width to 50 pd.set_option('display.max_columns', 50) # Load example dataset df = pd.read_csv('https://www.dropbox.com/s/52cb7kcflr8qm2u/5kings_battles_v1.csv?dl=1') # Create variable with TRUE if stark is the attacker stark_attacker = df['attacker_king'] == "Robb Stark" # Create variable with TRUE if the attacker wins attacker_wins = df['attacker_outcome'] == "win" # Select all cases where stark is the attacker and the attacker wins df[stark_attacker & attacker_wins] # Select the rows where attacker_2 is not missing, and defender_2 is not missing df[df['attacker_2'].notnull() & df['defender_2'].notnull()]