text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import re
sns.set(color_codes=True, style='darkgrid')

games = pd.read_csv('../input/games.csv')

games = games[games.rated]
games['mean_rating'] = (games.white_rating + games.black_rating) / 2
games['rating_diff'] = abs(games.white_rating - games.black_rating)

games.victory_status.value_counts()

under_1500 = games[games.mean_rating < 1500]
under_2000 = games[games.mean_rating < 2000]
over_2000 = games[games.mean_rating > 2000]
brackets = [under_1500, under_2000, over_2000]
bracket_titles = ['Under 1500', 'Under 2000', 'Over 2000']

for i, bracket in enumerate(brackets):
    victory_status = bracket.victory_status.value_counts()

mate_games = games[games.victory_status == 'mate']
under_1500 = mate_games[mate_games.mean_rating < 1500]
under_2000 = mate_games[mate_games.mean_rating < 2000]
over_2000 = mate_games[mate_games.mean_rating > 2000]
m_brackets = [under_1500, under_2000, over_2000]

turn_means = [b.turns.mean() for b in m_brackets]
plt.ylim(0, 100)

mate_games.loc[mate_games['turns'].idxmax()]