[{"data":1,"prerenderedAt":4281},["ShallowReactive",2],{"navigation":3,"/blog/chess-games":22,"/blog/chess-games-surround":426,"mdc-30pbux-key":429,"mdc--vsasgt-key":448,"snippet-/blog/chess-games/snippets/descriptive-stats":457,"snippet-/blog/chess-games/snippets/cleaning":2628,"snippet-/blog/chess-games/snippets/cleaning-output":3029,"snippet-/blog/chess-games/snippets/time-eval":3049},[4],{"title":5,"path":6,"stem":7,"children":8,"page":21},"Blog","/blog","blog",[9,15],{"title":10,"path":11,"stem":12,"children":13},"Does spending more time on a chess move increase its quality?","/blog/chess-games","blog/chess-games/index",[14],{"title":10,"path":11,"stem":12},{"title":16,"path":17,"stem":18,"children":19},"Building custom HTML reports using Qlik Automate","/blog/html-automation","blog/html-automation/index",[20],{"title":16,"path":17,"stem":18},false,{"id":23,"title":10,"body":24,"date":417,"description":418,"draft":21,"extension":419,"image":420,"meta":421,"minRead":422,"navigation":423,"path":11,"seo":424,"stem":12,"__hash__":425},"blog/blog/chess-games/index.md",{"type":25,"value":26,"toc":406},"minimark",[27,32,59,74,98,107,116,125,130,185,193,197,200,205,210,213,216,219,222,228,232,235,238,241,245,248,252,255,258,261,264,268,271,275,279,282,292,307,313,321,329,342,346,353,363,366,386,389,392,395,397,400,402],[28,29,31],"h2",{"id":30},"dataset-domain-understanding","Dataset & Domain Understanding",[33,34,35,36,46,47,52,53,58],"p",{},"Analysis will be done using Python 3.12. Specifically, the ",[37,38,45],"a",{"href":39,"rel":40,"target":44},"https://pandas.pydata.org/",[41,42,43],"nofollow","noopener","noreferrer","_blank","Pandas"," and NumPy packages for analysis and data cleaning, along with Matplotlib and Seaborn for visualizations.\nThese are the tools I started with when learning data analysis, although I'm very interested in trying out alternatives like ",[37,48,51],{"href":49,"rel":50,"target":44},"https://pola.rs/",[41,42,43],"Polars"," or ",[37,54,57],{"href":55,"rel":56,"target":44},"https://plotly.com/product-tour/",[41,42,43],"Plotly",", which I plan to write an article about in the near future.",[33,60,61,62,67,68,73],{},"The dataset comes from ",[37,63,66],{"href":64,"rel":65,"target":44},"https://web.chessdigits.com/data",[41,42,43],"Chessdigits.com",", who scraped and cleaned 200.000 online games. They were played on the ",[37,69,72],{"href":70,"rel":71,"target":44},"https://lichess.org",[41,42,43],"Lichess"," website, the second most popular place to play chess on the internet, in 2019. Each row represents one game. The two most important columns for this analysis are:",[75,76,77,90],"ul",{},[78,79,80,84,85,89],"li",{},[81,82,83],"strong",{},"Eval_ply_x:"," the computer evaluation of the position ",[86,87,88],"em",{},"after"," the last played move",[78,91,92,95,96,89],{},[81,93,94],{},"Clock_ply_x:"," the player's remaining time ",[86,97,88],{},[99,100,101],"blockquote",{},[33,102,103,106],{},[86,104,105],{},"'ply'"," in chess means half of a move: so when white starts, their move is ply 1, black's response is ply 2, white's next move is ply 3, and so on.",[33,108,109,110,115],{},"Both of these columns go up to 200 ply, but most games will have a lot of missing values towards the end of that range.\nThe computer evaluation is based on the best move according to a chess playing computer like ",[37,111,114],{"href":112,"rel":113,"target":44},"https://www.chess.com/terms/stockfish-chess-engine",[41,42,43],"Stockfish",", and as we'll see later on, it's not always the perfect way to judge which player has the better or easier to play position.",[99,117,118],{},[33,119,120,121,124],{},"When computer evaluations go below zero, this means black has the better position. If they are positive, then ",[86,122,123],{},"white has the better position",". The unit of measurement for evaluations is called centipawns, as +/- 1 is roughly understood to be an advantage equal to starting the game with one more pawn than your opponent.",[33,126,127],{},[81,128,129],{},"Other important columns include:",[75,131,132,138,150,171],{},[78,133,134,137],{},[81,135,136],{},"Opening:"," the common name for the first couple of moves made in the game",[78,139,140,143,144,149],{},[81,141,142],{},"[White/Black]Rating:"," the ",[37,145,148],{"href":146,"rel":147,"target":44},"https://www.chess.com/terms/elo-rating-chess",[41,42,43],"ELO Rating"," of each of the players. It is a historically tried and true measure of their relative strength.",[78,151,152,155,156,159,160,163,164,167,168],{},[81,153,154],{},"TimeControl:"," in the form ",[81,157,158],{},"'N+K'",", where ",[81,161,162],{},"N"," is the number of minutes each player starts with, and ",[81,165,166],{},"K"," is their ",[86,169,170],{},"increment",[78,172,173,176,177,180,181,184],{},[81,174,175],{},"Event:"," a categorical grouping of the time control, into ",[86,178,179],{},"Ultrabullet, Bullet, Blitz, Rapid"," and ",[86,182,183],{},"Classical",".",[99,186,187],{},[33,188,189,190,192],{},"Increment is the amount of time that gets added to a player's game clock ",[81,191,88],{}," making a move. If a player's clock reaches 0, they lose instantly, even if a move they were just about to make would have added time to their clock.",[28,194,196],{"id":195},"exploratory-data-analysis","Exploratory Data Analysis",[33,198,199],{},"The first step in understanding the dataset is to calculate some descriptive statistics. Below are histograms of the most important features that describe the games, such as the rating of the players, the length of the game, and more. Originally the code block below contained 5 lines of brute-force 'code', where I wrote out the lists containing the rating ranges and labels manually after looking through the data, before realising that this approach kind of defeats the purpose of programming. So I wrote a function that will create the rating ranges before plotting, ensuring the graph will still look correct even after the data cleaning process. The result is a quite a couple of lines longer, and took more time to write, but is also a lot more reusable and taught me a lesson; a tradeoff I am more than willing to make.",[201,202],"code-snippet",{"file":203,":collapsible":204},"descriptive-stats","true",[206,207],"enlarge-image",{":background":204,"alt":208,"src":209},"Descriptive statistics before cleaning","/blog/chess-games/EDA_before.png",[33,211,212],{},"From this, we see there's some anomalies that can be removed to get a clearer picture. Rules infractions and abandoned games can go, as well as games where the result seems inconclusive ('*' in the result column). I considered removing draws as well since they only comprise of a small amount of games but their inclusion doesn't hurt our results so I decided to leave them in. I also removed bullet and ultra bullet games since they are so short that no meaningful fluctuation in time spent can be observed.",[33,214,215],{},"Increment has a lot of unusual values which are not commonly used. This is probably due to people creating custom game challenges with less used or obscure time controls.\nWe can remove the odd ones out to get a clearer picture of the ones that are commonly found in online chess games.",[33,217,218],{},"99% of games are a total of 75 moves or shorter, which indicates that we can remove the last 50 ply without losing much data, significantly speeding up the analysis, as well as reducing the skewness of those distributions. We cut off some games before their conclusion, but since we're analyzing on a per-move basis, this should pose too much of a problem .",[33,220,221],{},"Finally, to reduce the skew of the rating distribution and make the results more applicable to the general population, we will only look at games with a maximum rating of 2500 for either player, and a rating difference of no more than 200 between them. This is to remove any confounding factors such as the stress / complacency of playing against a higher or lower rated player, respectively.",[33,223,224,225],{},"It's possible that Blitz games prove to be too short as well, so we might revisit this at a later moment.\nBut for now, ",[86,226,227],{},"let's clean some data!",[28,229,231],{"id":230},"data-cleaning","Data cleaning",[201,233],{"file":234},"cleaning",[201,236],{"file":237},"cleaning-output",[33,239,240],{},"These relatively simple filters make the dataset more normalized and remove outliers on key features.\nNow we can plot the descriptive stats again to see if things improved:",[206,242],{":background":204,"alt":243,"src":244},"After EDA","/blog/chess-games/EDA_after.png",[33,246,247],{},"Those graphs already look a lot cleaner.\nRating distribution skewness went from 0.24 to 0.14, and game length skewness from 1.17 to 0.68. This makes the distribution measurably more symmetrical.\nRemoving the odd increments also decreases the influence that rare custom time controls have on the data.",[28,249,251],{"id":250},"extracting-time-and-evaluation-difference","Extracting Time and Evaluation Difference",[33,253,254],{},"To be able to answer our research question, we need to make a dataframe containing the time spent on each move, together with the evaluation difference between that move and the next one. An important factor to include is the increment the player gets, as it will be added to the clock after each move and thus isn't actually time spent on making the move itself.",[33,256,257],{},"First, we make filtered dataframes containing only the relevant columns. Then we combine those, before finally starting on the bulk of the data processing for this project. The final pipeline is the result of a lot of trial and error, pushing my Python skills to it's limit.",[33,259,260],{},"I've tried to explain my thought process as much as possible, but if you just want to go to the results, you can click the button below to collapse the code.",[201,262],{"file":263,":collapsible":204},"time-eval",[28,265,267],{"id":266},"results","Results",[33,269,270],{},"Now that we have our DataFrame on a per move basis, a second round of data examination and cleaning begins.\nFirst, let's look at the boxplots for evaluation change and time spent to check for any outliers. The scatterplot also helps show how the data is distributed.",[206,272],{":background":204,"alt":273,"src":274},"Move evaluation boxplot","/blog/chess-games/move_eval_boxplot.png",[206,276],{":background":204,"alt":277,"src":278},"Evaluation time spend scatterplot","/blog/chess-games/eval_time_scatter.png",[33,280,281],{},"There are some unexpected things happening here:",[33,283,284,291],{},[86,285,286,287,290],{},"Some moves seem to take ",[86,288,289],{},"negative time"," to make",", even after taking the increment into account.\nWhile it could potentially be an error in the code, this is likely due to a feature on lichess where your opponent can give you extra time on your clock,\nwhich will show up as negative time spent on that move.\nSome of the extremely large time spent values can also be due to this feature, as it allows a player to have much more time on their clock than the format should allow. With some exceptions, most of the large time spent comes from classical games, which can last for hours, so that makes sense.",[33,293,294,295,298,299,302,303,306],{},"This is also where we see a problem arise with the ",[81,296,297],{},"interpretability of computer evaluations",".\nDuring the processing, we ommitted any move where the current or previous move contained a forced mate evaluation, as those cannot be easily converted into a numerical value. Mate in one, two or three moves can be conceptualized as being relatively easy to find, but if the computer sees forced mate in 20 moves, and ",[86,300,301],{},"every other sequence of moves"," leads to a much worse position, the position will be ",[81,304,305],{},"much worse in practical terms",". A chess computer has no idea on how to differentiate those, as the evaluation of a position is based on the best move in that position.\nSimilarly, when a position is really good but the computer can't find a sequence leading to forced mate, it can produce some crazy high evaluations.",[33,308,309,312],{},[81,310,311],{},"Good to know:"," chess evaluation is supposed to be mapped back to the value of the pieces. So if the evaluation is +9, this should roughly mean white is up the equivalent of a full queen.",[99,314,315],{},[33,316,317,320],{},[81,318,319],{},"This leads to some questions about interpretability",":",[75,322,323,326],{},[78,324,325],{},"If the evaluation is already +20 for your opponent, and your move takes it to +50, did the position get worse in human terms?",[78,327,328],{},"If the inverse happens, and you manage to 'only' be down the equivalent of two queens instead of four, did your chances to win really improve?",[33,330,331,332,335,336,341],{},"In other words, ",[81,333,334],{},"computer evaluation cannot be seen as a continuous scale on which to evaluate a position",". Go past a threshold of, say, 10 and subsequent increases start to matter less and less, in practical human terms.\nComparison with the second best computer move would provide some insight into how critical finding a specific move is, but that isn't available in this dataset.\nFor more analysis about the relationship between computer evaluation and winning chances, check out ",[37,337,340],{"href":338,"rel":339,"target":44},"https://web.chessdigits.com/articles/when-should-you-resign",[41,42,43],"this article"," by the creator of the dataset.",[28,343,345],{"id":344},"whats-next","What's next?",[33,347,348,349,352],{},"Originally, and perhaps naively, I was planning to just do regression and correlation analyses on the extracted data.\nBut after delving into the results, it seems that it is very hard to obtain useful insights from computer evaluation change ",[81,350,351],{},"as an absolute numerical value",".\nIts value and relevancy fluctuates too drastically based on how close to 0 it is.",[33,354,355,356,359,360,184],{},"A more reasonable approach would be to turn evaluation changes into ",[81,357,358],{},"categories",":\nAnalyzing data like this removes the scale problem of evaluations, and focuses on the question at hand; if spending more time leads to fewer ",[86,361,362],{},"mistakes",[33,364,365],{},"To address this, we can categorize evaluation changes into three main types:",[75,367,368,374,380],{},[78,369,370,373],{},[81,371,372],{},"Blunder:"," A move that drastically worsens the evaluation, turning a balanced or winning position into a losing one.",[78,375,376,379],{},[81,377,378],{},"Mistake:"," A move that worsens the evaluation, but not as severely as a blunder, reducing a winning advantage to a smaller one.",[78,381,382,385],{},[81,383,384],{},"Inaccuracy:"," A move that slightly worsens the evaluation, but doesn't change the overall assessment of the position.",[33,387,388],{},"By grouping moves this way, we can analyze whether spending more time reduces the frequency of blunders and mistakes, rather than focusing on raw evaluation numbers.\nThis approach aligns better with how chess players and coaches assess move quality in practical terms.",[390,391],"br",{},[393,394],"hr",{},[390,396],{},[33,398,399],{},"For those of you that have read this post all the way through, thank you so much! Your attention and support means a lot to me.\nAs a parting gift, I made this nice graph of the top 20 most commonly played openings in the dataset. Check it out below!",[390,401],{},[206,403],{":background":204,"alt":404,"src":405},"Win percentage graph","/blog/chess-games/win_percentages_transparent.png",{"title":407,"searchDepth":408,"depth":408,"links":409},"",3,[410,412,413,414,415,416],{"id":30,"depth":411,"text":31},2,{"id":195,"depth":411,"text":196},{"id":230,"depth":411,"text":231},{"id":250,"depth":411,"text":251},{"id":266,"depth":411,"text":267},{"id":344,"depth":411,"text":345},"2025-11-14","Chess is as much about finding the best move as it is about managing your available time, but does going *'into the tank'* actually result in a better move? \nI analyze hundreds of thousands of moves across 200.000 games, and learn a thing or two about continuous variables in the process.\n","md","/blog/chess-games/cover.jpg",{},null,true,{"title":10,"description":418},"jptXXDPmmiofQSZ6SDEdchQpU5JKj2pn_Nq4IJpFdPI",[422,427],{"title":16,"path":17,"stem":18,"description":428,"children":-1},"Sometimes, when all out-of-the-box solutions fall short, you have to come up with your own.\n\nRead here how I solved a reporting problem using tools beyond what they were originally meant for.\n",{"data":430,"body":431},{},{"type":432,"children":433},"root",[434],{"type":435,"tag":33,"props":436,"children":437},"element",{},[438,441,446],{"type":439,"value":440},"text","Chess is as much about finding the best move as it is about managing your available time, but does going ",{"type":435,"tag":86,"props":442,"children":443},{},[444],{"type":439,"value":445},"'into the tank'",{"type":439,"value":447}," actually result in a better move?\nI analyze hundreds of thousands of moves across 200.000 games, and learn a thing or two about continuous variables in the process.",{"data":449,"body":450},{},{"type":432,"children":451},[452],{"type":435,"tag":33,"props":453,"children":454},{},[455],{"type":439,"value":456},"Sometimes, when all out-of-the-box solutions fall short, you have to come up with your own.\nRead here how I solved a reporting problem using tools beyond what they were originally meant for.",{"id":458,"title":459,"body":460,"description":407,"extension":419,"language":422,"meta":2623,"name":422,"navigation":423,"path":2624,"seo":2625,"stem":2626,"__hash__":2627},"snippet/blog/chess-games/snippets/descriptive-stats.md","Descriptive Stats",{"type":25,"value":461,"toc":2621},[462,1089,1092,1462,1465,2617],[463,464,468],"pre",{"className":465,"code":466,"language":467,"meta":407,"style":407},"language-python shiki shiki-themes catppuccin-latte catppuccin-latte catppuccin-macchiato","def get_rating_ranges(df, bin_size=100):\n    # Get min and max ratings amongst both colors\n    min_rating = min(df['WhiteElo'].min(), df['BlackElo'].min())\n    max_rating = max(df['WhiteElo'].max(), df['BlackElo'].max())\n\n    # Round min down and max up to nearest bin_size\n    min_rating = (min_rating // bin_size) * bin_size\n    max_rating = ((max_rating // bin_size) + 1) * bin_size\n\n    # Create bins\n    rating_bins = list(range(min_rating, max_rating + bin_size, bin_size))\n\n    # Create labels\n    rating_labels = [\n        f'{bin_start} - {bin_start + bin_size - 1}'\n        for bin_start in rating_bins[:-1]\n    ]\n    rating_labels[-1] = f'{rating_bins[-2]}+'  # Indicate the last bin's upper bound\n\n    # Create rating ranges\n    df['WhiteRatingRange'] = pd.cut(df['WhiteElo'], bins=rating_bins, labels=rating_labels)\n    df['BlackRatingRange'] = pd.cut(df['BlackElo'], bins=rating_bins, labels=rating_labels)\n\n    # Combine ranges\n    combined_rating_range = pd.concat([df['WhiteRatingRange'], df['BlackRatingRange']], ignore_index=True)\n\n    return rating_labels, combined_rating_range\n","python",[469,470,471,509,515,573,619,625,631,658,689,694,700,739,744,750,761,802,828,834,879,884,890,952,1006,1011,1017,1070,1075],"code",{"__ignoreMap":407},[472,473,476,480,484,488,492,495,498,502,506],"span",{"class":474,"line":475},"line",1,[472,477,479],{"class":478},"sTQ8l","def",[472,481,483],{"class":482},"sZJYN"," get_rating_ranges",[472,485,487],{"class":486},"shMcR","(",[472,489,491],{"class":490},"s1dUP","df",[472,493,494],{"class":486},",",[472,496,497],{"class":490}," bin_size",[472,499,501],{"class":500},"saHHS","=",[472,503,505],{"class":504},"sI2Su","100",[472,507,508],{"class":486},"):\n",[472,510,511],{"class":474,"line":411},[472,512,514],{"class":513},"se-gO","    # Get min and max ratings amongst both colors\n",[472,516,517,521,523,527,529,531,534,538,542,544,547,551,554,557,559,561,564,566,568,570],{"class":474,"line":408},[472,518,520],{"class":519},"swLP3","    min_rating ",[472,522,501],{"class":500},[472,524,526],{"class":525},"sV1I6"," min",[472,528,487],{"class":486},[472,530,491],{"class":490},[472,532,533],{"class":486},"[",[472,535,537],{"class":536},"sPevk","'",[472,539,541],{"class":540},"s3e4v","WhiteElo",[472,543,537],{"class":536},[472,545,546],{"class":486},"].",[472,548,550],{"class":549},"sBYUN","min",[472,552,553],{"class":486},"(),",[472,555,556],{"class":490}," df",[472,558,533],{"class":486},[472,560,537],{"class":536},[472,562,563],{"class":540},"BlackElo",[472,565,537],{"class":536},[472,567,546],{"class":486},[472,569,550],{"class":549},[472,571,572],{"class":486},"())\n",[472,574,576,579,581,584,586,588,590,592,594,596,598,601,603,605,607,609,611,613,615,617],{"class":474,"line":575},4,[472,577,578],{"class":519},"    max_rating ",[472,580,501],{"class":500},[472,582,583],{"class":525}," max",[472,585,487],{"class":486},[472,587,491],{"class":490},[472,589,533],{"class":486},[472,591,537],{"class":536},[472,593,541],{"class":540},[472,595,537],{"class":536},[472,597,546],{"class":486},[472,599,600],{"class":549},"max",[472,602,553],{"class":486},[472,604,556],{"class":490},[472,606,533],{"class":486},[472,608,537],{"class":536},[472,610,563],{"class":540},[472,612,537],{"class":536},[472,614,546],{"class":486},[472,616,600],{"class":549},[472,618,572],{"class":486},[472,620,622],{"class":474,"line":621},5,[472,623,624],{"emptyLinePlaceholder":423},"\n",[472,626,628],{"class":474,"line":627},6,[472,629,630],{"class":513},"    # Round min down and max up to nearest bin_size\n",[472,632,634,636,638,641,644,647,649,652,655],{"class":474,"line":633},7,[472,635,520],{"class":519},[472,637,501],{"class":500},[472,639,640],{"class":486}," (",[472,642,643],{"class":519},"min_rating ",[472,645,646],{"class":500},"//",[472,648,497],{"class":519},[472,650,651],{"class":486},")",[472,653,654],{"class":500}," *",[472,656,657],{"class":519}," bin_size\n",[472,659,661,663,665,668,671,673,675,677,680,683,685,687],{"class":474,"line":660},8,[472,662,578],{"class":519},[472,664,501],{"class":500},[472,666,667],{"class":486}," ((",[472,669,670],{"class":519},"max_rating ",[472,672,646],{"class":500},[472,674,497],{"class":519},[472,676,651],{"class":486},[472,678,679],{"class":500}," +",[472,681,682],{"class":504}," 1",[472,684,651],{"class":486},[472,686,654],{"class":500},[472,688,657],{"class":519},[472,690,692],{"class":474,"line":691},9,[472,693,624],{"emptyLinePlaceholder":423},[472,695,697],{"class":474,"line":696},10,[472,698,699],{"class":513},"    # Create bins\n",[472,701,703,706,708,712,714,717,719,722,724,727,730,732,734,736],{"class":474,"line":702},11,[472,704,705],{"class":519},"    rating_bins ",[472,707,501],{"class":500},[472,709,711],{"class":710},"sdQ9k"," list",[472,713,487],{"class":486},[472,715,716],{"class":525},"range",[472,718,487],{"class":486},[472,720,721],{"class":519},"min_rating",[472,723,494],{"class":486},[472,725,726],{"class":519}," max_rating ",[472,728,729],{"class":500},"+",[472,731,497],{"class":519},[472,733,494],{"class":486},[472,735,497],{"class":519},[472,737,738],{"class":486},"))\n",[472,740,742],{"class":474,"line":741},12,[472,743,624],{"emptyLinePlaceholder":423},[472,745,747],{"class":474,"line":746},13,[472,748,749],{"class":513},"    # Create labels\n",[472,751,753,756,758],{"class":474,"line":752},14,[472,754,755],{"class":519},"    rating_labels ",[472,757,501],{"class":500},[472,759,760],{"class":486}," [\n",[472,762,764,767,769,773,776,779,782,784,787,789,792,795,797,799],{"class":474,"line":763},15,[472,765,766],{"class":540},"        f",[472,768,537],{"class":536},[472,770,772],{"class":771},"siCgW","{",[472,774,775],{"class":519},"bin_start",[472,777,778],{"class":771},"}",[472,780,781],{"class":536}," - ",[472,783,772],{"class":771},[472,785,786],{"class":519},"bin_start ",[472,788,729],{"class":500},[472,790,791],{"class":519}," bin_size ",[472,793,794],{"class":500},"-",[472,796,682],{"class":504},[472,798,778],{"class":771},[472,800,801],{"class":536},"'\n",[472,803,805,808,811,814,817,820,822,825],{"class":474,"line":804},16,[472,806,807],{"class":478},"        for",[472,809,810],{"class":519}," bin_start ",[472,812,813],{"class":478},"in",[472,815,816],{"class":490}," rating_bins",[472,818,819],{"class":486},"[:",[472,821,794],{"class":500},[472,823,824],{"class":525},"1",[472,826,827],{"class":486},"]\n",[472,829,831],{"class":474,"line":830},17,[472,832,833],{"class":486},"    ]\n",[472,835,837,840,842,844,846,849,852,855,857,859,862,864,866,869,871,873,876],{"class":474,"line":836},18,[472,838,839],{"class":490},"    rating_labels",[472,841,533],{"class":486},[472,843,794],{"class":500},[472,845,824],{"class":525},[472,847,848],{"class":486},"]",[472,850,851],{"class":500}," =",[472,853,854],{"class":540}," f",[472,856,537],{"class":536},[472,858,772],{"class":771},[472,860,861],{"class":490},"rating_bins",[472,863,533],{"class":486},[472,865,794],{"class":500},[472,867,868],{"class":525},"2",[472,870,848],{"class":486},[472,872,778],{"class":771},[472,874,875],{"class":536},"+'",[472,877,878],{"class":513},"  # Indicate the last bin's upper bound\n",[472,880,882],{"class":474,"line":881},19,[472,883,624],{"emptyLinePlaceholder":423},[472,885,887],{"class":474,"line":886},20,[472,888,889],{"class":513},"    # Create rating ranges\n",[472,891,893,896,898,900,903,905,907,909,912,914,917,919,921,923,925,927,929,932,935,937,939,941,944,946,949],{"class":474,"line":892},21,[472,894,895],{"class":490},"    df",[472,897,533],{"class":486},[472,899,537],{"class":536},[472,901,902],{"class":540},"WhiteRatingRange",[472,904,537],{"class":536},[472,906,848],{"class":486},[472,908,851],{"class":500},[472,910,911],{"class":519}," pd",[472,913,184],{"class":486},[472,915,916],{"class":549},"cut",[472,918,487],{"class":486},[472,920,491],{"class":490},[472,922,533],{"class":486},[472,924,537],{"class":536},[472,926,541],{"class":540},[472,928,537],{"class":536},[472,930,931],{"class":486},"],",[472,933,934],{"class":490}," bins",[472,936,501],{"class":500},[472,938,861],{"class":519},[472,940,494],{"class":486},[472,942,943],{"class":490}," labels",[472,945,501],{"class":500},[472,947,948],{"class":519},"rating_labels",[472,950,951],{"class":486},")\n",[472,953,955,957,959,961,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004],{"class":474,"line":954},22,[472,956,895],{"class":490},[472,958,533],{"class":486},[472,960,537],{"class":536},[472,962,963],{"class":540},"BlackRatingRange",[472,965,537],{"class":536},[472,967,848],{"class":486},[472,969,851],{"class":500},[472,971,911],{"class":519},[472,973,184],{"class":486},[472,975,916],{"class":549},[472,977,487],{"class":486},[472,979,491],{"class":490},[472,981,533],{"class":486},[472,983,537],{"class":536},[472,985,563],{"class":540},[472,987,537],{"class":536},[472,989,931],{"class":486},[472,991,934],{"class":490},[472,993,501],{"class":500},[472,995,861],{"class":519},[472,997,494],{"class":486},[472,999,943],{"class":490},[472,1001,501],{"class":500},[472,1003,948],{"class":519},[472,1005,951],{"class":486},[472,1007,1009],{"class":474,"line":1008},23,[472,1010,624],{"emptyLinePlaceholder":423},[472,1012,1014],{"class":474,"line":1013},24,[472,1015,1016],{"class":513},"    # Combine ranges\n",[472,1018,1020,1023,1025,1027,1029,1032,1035,1037,1039,1041,1043,1045,1047,1049,1051,1053,1055,1057,1060,1063,1065,1068],{"class":474,"line":1019},25,[472,1021,1022],{"class":519},"    combined_rating_range ",[472,1024,501],{"class":500},[472,1026,911],{"class":519},[472,1028,184],{"class":486},[472,1030,1031],{"class":549},"concat",[472,1033,1034],{"class":486},"([",[472,1036,491],{"class":490},[472,1038,533],{"class":486},[472,1040,537],{"class":536},[472,1042,902],{"class":540},[472,1044,537],{"class":536},[472,1046,931],{"class":486},[472,1048,556],{"class":490},[472,1050,533],{"class":486},[472,1052,537],{"class":536},[472,1054,963],{"class":540},[472,1056,537],{"class":536},[472,1058,1059],{"class":486},"]],",[472,1061,1062],{"class":490}," ignore_index",[472,1064,501],{"class":500},[472,1066,1067],{"class":504},"True",[472,1069,951],{"class":486},[472,1071,1073],{"class":474,"line":1072},26,[472,1074,624],{"emptyLinePlaceholder":423},[472,1076,1078,1081,1084,1086],{"class":474,"line":1077},27,[472,1079,1080],{"class":478},"    return",[472,1082,1083],{"class":519}," rating_labels",[472,1085,494],{"class":486},[472,1087,1088],{"class":519}," combined_rating_range\n",[33,1090,1091],{},"Feeling good about this refactor, I decided to write a similar function for the game length. The time control and increment will only be added to the dataframe once and thus don't need to be included in a function.",[463,1093,1095],{"className":465,"code":1094,"language":467,"meta":407,"style":407},"df['GameMode'] = df['Event'].str.split().str[1]\ndf['Increment'] = df['TimeControl'].str.split('+').str[1].astype('int')\ndf['IncrementCategory'] = df['Increment'].astype('category')\n\n\ndef get_game_length(df):\n    move_columns = [col for col in df.columns if col.startswith('Move_ply_')]\n    game_length_df = df[['Index']].copy()\n    game_length_df['game_length'] = (\n        (pd.Index(df[move_columns].isna().idxmax(axis=1)).str.extract('(\\d+)').astype(float) + 1) // 2\n    ).astype(int)\n    return game_length_df\n",[469,1096,1097,1146,1208,1246,1250,1254,1267,1314,1342,1363,1441,1455],{"__ignoreMap":407},[472,1098,1099,1101,1103,1105,1108,1110,1112,1114,1116,1118,1120,1123,1125,1127,1130,1132,1135,1138,1140,1142,1144],{"class":474,"line":475},[472,1100,491],{"class":490},[472,1102,533],{"class":486},[472,1104,537],{"class":536},[472,1106,1107],{"class":540},"GameMode",[472,1109,537],{"class":536},[472,1111,848],{"class":486},[472,1113,851],{"class":500},[472,1115,556],{"class":490},[472,1117,533],{"class":486},[472,1119,537],{"class":536},[472,1121,1122],{"class":540},"Event",[472,1124,537],{"class":536},[472,1126,546],{"class":486},[472,1128,1129],{"class":519},"str",[472,1131,184],{"class":486},[472,1133,1134],{"class":549},"split",[472,1136,1137],{"class":486},"().",[472,1139,1129],{"class":490},[472,1141,533],{"class":486},[472,1143,824],{"class":525},[472,1145,827],{"class":486},[472,1147,1148,1150,1152,1154,1157,1159,1161,1163,1165,1167,1169,1172,1174,1176,1178,1180,1182,1184,1187,1190,1192,1194,1196,1198,1201,1203,1206],{"class":474,"line":411},[472,1149,491],{"class":490},[472,1151,533],{"class":486},[472,1153,537],{"class":536},[472,1155,1156],{"class":540},"Increment",[472,1158,537],{"class":536},[472,1160,848],{"class":486},[472,1162,851],{"class":500},[472,1164,556],{"class":490},[472,1166,533],{"class":486},[472,1168,537],{"class":536},[472,1170,1171],{"class":540},"TimeControl",[472,1173,537],{"class":536},[472,1175,546],{"class":486},[472,1177,1129],{"class":519},[472,1179,184],{"class":486},[472,1181,1134],{"class":549},[472,1183,487],{"class":486},[472,1185,1186],{"class":536},"'+'",[472,1188,1189],{"class":486},").",[472,1191,1129],{"class":490},[472,1193,533],{"class":486},[472,1195,824],{"class":525},[472,1197,546],{"class":486},[472,1199,1200],{"class":549},"astype",[472,1202,487],{"class":486},[472,1204,1205],{"class":536},"'int'",[472,1207,951],{"class":486},[472,1209,1210,1212,1214,1216,1219,1221,1223,1225,1227,1229,1231,1233,1235,1237,1239,1241,1244],{"class":474,"line":408},[472,1211,491],{"class":490},[472,1213,533],{"class":486},[472,1215,537],{"class":536},[472,1217,1218],{"class":540},"IncrementCategory",[472,1220,537],{"class":536},[472,1222,848],{"class":486},[472,1224,851],{"class":500},[472,1226,556],{"class":490},[472,1228,533],{"class":486},[472,1230,537],{"class":536},[472,1232,1156],{"class":540},[472,1234,537],{"class":536},[472,1236,546],{"class":486},[472,1238,1200],{"class":549},[472,1240,487],{"class":486},[472,1242,1243],{"class":536},"'category'",[472,1245,951],{"class":486},[472,1247,1248],{"class":474,"line":575},[472,1249,624],{"emptyLinePlaceholder":423},[472,1251,1252],{"class":474,"line":621},[472,1253,624],{"emptyLinePlaceholder":423},[472,1255,1256,1258,1261,1263,1265],{"class":474,"line":627},[472,1257,479],{"class":478},[472,1259,1260],{"class":482}," get_game_length",[472,1262,487],{"class":486},[472,1264,491],{"class":490},[472,1266,508],{"class":486},[472,1268,1269,1272,1274,1277,1280,1283,1286,1288,1290,1292,1295,1298,1301,1303,1306,1308,1311],{"class":474,"line":633},[472,1270,1271],{"class":519},"    move_columns ",[472,1273,501],{"class":500},[472,1275,1276],{"class":486}," [",[472,1278,1279],{"class":519},"col ",[472,1281,1282],{"class":478},"for",[472,1284,1285],{"class":519}," col ",[472,1287,813],{"class":478},[472,1289,556],{"class":519},[472,1291,184],{"class":486},[472,1293,1294],{"class":519},"columns ",[472,1296,1297],{"class":478},"if",[472,1299,1300],{"class":519}," col",[472,1302,184],{"class":486},[472,1304,1305],{"class":549},"startswith",[472,1307,487],{"class":486},[472,1309,1310],{"class":536},"'Move_ply_'",[472,1312,1313],{"class":486},")]\n",[472,1315,1316,1319,1321,1323,1326,1328,1331,1333,1336,1339],{"class":474,"line":660},[472,1317,1318],{"class":519},"    game_length_df ",[472,1320,501],{"class":500},[472,1322,556],{"class":490},[472,1324,1325],{"class":486},"[[",[472,1327,537],{"class":536},[472,1329,1330],{"class":540},"Index",[472,1332,537],{"class":536},[472,1334,1335],{"class":486},"]].",[472,1337,1338],{"class":549},"copy",[472,1340,1341],{"class":486},"()\n",[472,1343,1344,1347,1349,1351,1354,1356,1358,1360],{"class":474,"line":691},[472,1345,1346],{"class":490},"    game_length_df",[472,1348,533],{"class":486},[472,1350,537],{"class":536},[472,1352,1353],{"class":540},"game_length",[472,1355,537],{"class":536},[472,1357,848],{"class":486},[472,1359,851],{"class":500},[472,1361,1362],{"class":486}," (\n",[472,1364,1365,1368,1371,1373,1375,1377,1379,1381,1384,1386,1389,1391,1394,1396,1399,1401,1403,1406,1408,1410,1413,1415,1418,1420,1422,1424,1427,1429,1431,1433,1435,1438],{"class":474,"line":696},[472,1366,1367],{"class":486},"        (",[472,1369,1370],{"class":519},"pd",[472,1372,184],{"class":486},[472,1374,1330],{"class":549},[472,1376,487],{"class":486},[472,1378,491],{"class":490},[472,1380,533],{"class":486},[472,1382,1383],{"class":490},"move_columns",[472,1385,546],{"class":486},[472,1387,1388],{"class":549},"isna",[472,1390,1137],{"class":486},[472,1392,1393],{"class":549},"idxmax",[472,1395,487],{"class":486},[472,1397,1398],{"class":490},"axis",[472,1400,501],{"class":500},[472,1402,824],{"class":504},[472,1404,1405],{"class":486},")).",[472,1407,1129],{"class":519},[472,1409,184],{"class":486},[472,1411,1412],{"class":549},"extract",[472,1414,487],{"class":486},[472,1416,1417],{"class":536},"'(\\d+)'",[472,1419,1189],{"class":486},[472,1421,1200],{"class":549},[472,1423,487],{"class":486},[472,1425,1426],{"class":710},"float",[472,1428,651],{"class":486},[472,1430,679],{"class":500},[472,1432,682],{"class":504},[472,1434,651],{"class":486},[472,1436,1437],{"class":500}," //",[472,1439,1440],{"class":504}," 2\n",[472,1442,1443,1446,1448,1450,1453],{"class":474,"line":702},[472,1444,1445],{"class":486},"    ).",[472,1447,1200],{"class":549},[472,1449,487],{"class":486},[472,1451,1452],{"class":710},"int",[472,1454,951],{"class":486},[472,1456,1457,1459],{"class":474,"line":741},[472,1458,1080],{"class":478},[472,1460,1461],{"class":519}," game_length_df\n",[33,1463,1464],{},"Finally, I added a function to plot the different histograms into one plot.",[463,1466,1468],{"className":465,"code":1467,"language":467,"meta":407,"style":407},"def display_distribution_statistics(df, file_name=None):\n    # Set the plot aesthetics\n    sns.set_style('darkgrid')\n    import matplotlib as mpl\n    mpl.rcParams['font.family'] = 'DejaVu Sans'\n\n    # Run all data creation functions\n    rating_labels, combined_rating_range = get_rating_ranges(df, bin_size=100)\n    game_length_df = get_game_length(df)\n\n    # Create the plot\n    fig, ((ax1, ax2), (ax3, ax4), (ax5, ax6)) = plt.subplots(3, 2, figsize=(14, 14))\n    fig.suptitle(\"Descriptive statistics\", fontsize=25)\n    sns.set_style('darkgrid')\n\n    # Rating distribution (ax1)\n    sns.histplot(ax=ax1, data=combined_rating_range, kde=True, kde_kws={'bw_adjust': 4})\n    ax1.set_title('Rating', fontsize=20)\n    ax1.set_xticklabels(rating_labels, rotation=60, ha='right', rotation_mode='anchor')\n    ax1.set_ylabel('')\n    ax1.set_axisbelow(True)\n\n    # Game terminations (ax2)\n    sns.histplot(ax=ax2, data=df, x='Termination')\n    ax2.set_title('Game termination', fontsize=20)\n    ax2.set_xlabel('')\n    ax2.set_ylabel('')\n\n    # Game length (ax3)\n    sns.histplot(ax=ax3, data=game_length_df, x='game_length', binwidth=5, kde=True)\n    ax3.set_title('Game length', fontsize=20)\n    ax3.set_xlabel('')\n    ax3.set_ylabel('')\n\n    # Game mode (ax4)\n    sns.histplot(ax=ax4, data=df, x='GameMode')\n    ax4.set_title('Game mode', fontsize=20)\n    ax4.set_xlabel('')\n    ax4.set_ylabel('')\n\n    # Game result (ax5)\n    sns.histplot(ax=ax5, data=df, x='Result')\n    ax5.set_title('Game result', fontsize=20)\n    ax5.set_xlabel('')\n    ax5.set_ylabel('')\n\n    # Increment counts (ax6)\n    increment_order = df['Increment'].value_counts(ascending=False).index\n    sns.countplot(ax=ax6, data=df, x='Increment', order=increment_order)\n    ax6.set_title('Increment', fontsize=20)\n    ax6.set_xlabel('')\n    ax6.set_ylabel('')\n\n    plt.tight_layout(rect=[0, 0, 1, 0.96])\n    if file_name:\n        plt.savefig(\n            file_name,\n            dpi=300,\n            bbox_inches='tight',\n            transparent=True,\n        )\n    plt.show()\n",[469,1469,1470,1493,1498,1515,1529,1555,1559,1564,1591,1605,1609,1614,1698,1724,1738,1742,1747,1804,1830,1875,1891,1906,1910,1915,1952,1976,1991,2005,2010,2016,2071,2096,2111,2126,2131,2137,2174,2199,2214,2229,2234,2240,2276,2301,2316,2331,2336,2342,2380,2428,2452,2467,2482,2487,2527,2538,2552,2561,2574,2587,2599,2605],{"__ignoreMap":407},[472,1471,1472,1474,1477,1479,1481,1483,1486,1488,1491],{"class":474,"line":475},[472,1473,479],{"class":478},[472,1475,1476],{"class":482}," display_distribution_statistics",[472,1478,487],{"class":486},[472,1480,491],{"class":490},[472,1482,494],{"class":486},[472,1484,1485],{"class":490}," file_name",[472,1487,501],{"class":500},[472,1489,1490],{"class":504},"None",[472,1492,508],{"class":486},[472,1494,1495],{"class":474,"line":411},[472,1496,1497],{"class":513},"    # Set the plot aesthetics\n",[472,1499,1500,1503,1505,1508,1510,1513],{"class":474,"line":408},[472,1501,1502],{"class":519},"    sns",[472,1504,184],{"class":486},[472,1506,1507],{"class":549},"set_style",[472,1509,487],{"class":486},[472,1511,1512],{"class":536},"'darkgrid'",[472,1514,951],{"class":486},[472,1516,1517,1520,1523,1526],{"class":474,"line":575},[472,1518,1519],{"class":478},"    import",[472,1521,1522],{"class":519}," matplotlib ",[472,1524,1525],{"class":478},"as",[472,1527,1528],{"class":519}," mpl\n",[472,1530,1531,1534,1536,1539,1541,1543,1546,1548,1550,1552],{"class":474,"line":621},[472,1532,1533],{"class":519},"    mpl",[472,1535,184],{"class":486},[472,1537,1538],{"class":490},"rcParams",[472,1540,533],{"class":486},[472,1542,537],{"class":536},[472,1544,1545],{"class":540},"font.family",[472,1547,537],{"class":536},[472,1549,848],{"class":486},[472,1551,851],{"class":500},[472,1553,1554],{"class":536}," 'DejaVu Sans'\n",[472,1556,1557],{"class":474,"line":627},[472,1558,624],{"emptyLinePlaceholder":423},[472,1560,1561],{"class":474,"line":633},[472,1562,1563],{"class":513},"    # Run all data creation functions\n",[472,1565,1566,1568,1570,1573,1575,1577,1579,1581,1583,1585,1587,1589],{"class":474,"line":660},[472,1567,839],{"class":519},[472,1569,494],{"class":486},[472,1571,1572],{"class":519}," combined_rating_range ",[472,1574,501],{"class":500},[472,1576,483],{"class":549},[472,1578,487],{"class":486},[472,1580,491],{"class":519},[472,1582,494],{"class":486},[472,1584,497],{"class":490},[472,1586,501],{"class":500},[472,1588,505],{"class":504},[472,1590,951],{"class":486},[472,1592,1593,1595,1597,1599,1601,1603],{"class":474,"line":691},[472,1594,1318],{"class":519},[472,1596,501],{"class":500},[472,1598,1260],{"class":549},[472,1600,487],{"class":486},[472,1602,491],{"class":519},[472,1604,951],{"class":486},[472,1606,1607],{"class":474,"line":696},[472,1608,624],{"emptyLinePlaceholder":423},[472,1610,1611],{"class":474,"line":702},[472,1612,1613],{"class":513},"    # Create the plot\n",[472,1615,1616,1619,1621,1623,1626,1628,1631,1634,1636,1639,1641,1644,1646,1648,1651,1653,1656,1659,1661,1664,1666,1669,1671,1674,1676,1679,1681,1684,1686,1688,1691,1693,1696],{"class":474,"line":741},[472,1617,1618],{"class":519},"    fig",[472,1620,494],{"class":486},[472,1622,667],{"class":486},[472,1624,1625],{"class":519},"ax1",[472,1627,494],{"class":486},[472,1629,1630],{"class":519}," ax2",[472,1632,1633],{"class":486},"),",[472,1635,640],{"class":486},[472,1637,1638],{"class":519},"ax3",[472,1640,494],{"class":486},[472,1642,1643],{"class":519}," ax4",[472,1645,1633],{"class":486},[472,1647,640],{"class":486},[472,1649,1650],{"class":519},"ax5",[472,1652,494],{"class":486},[472,1654,1655],{"class":519}," ax6",[472,1657,1658],{"class":486},"))",[472,1660,851],{"class":500},[472,1662,1663],{"class":519}," plt",[472,1665,184],{"class":486},[472,1667,1668],{"class":549},"subplots",[472,1670,487],{"class":486},[472,1672,1673],{"class":504},"3",[472,1675,494],{"class":486},[472,1677,1678],{"class":504}," 2",[472,1680,494],{"class":486},[472,1682,1683],{"class":490}," figsize",[472,1685,501],{"class":500},[472,1687,487],{"class":486},[472,1689,1690],{"class":504},"14",[472,1692,494],{"class":486},[472,1694,1695],{"class":504}," 14",[472,1697,738],{"class":486},[472,1699,1700,1702,1704,1707,1709,1712,1714,1717,1719,1722],{"class":474,"line":746},[472,1701,1618],{"class":519},[472,1703,184],{"class":486},[472,1705,1706],{"class":549},"suptitle",[472,1708,487],{"class":486},[472,1710,1711],{"class":536},"\"Descriptive statistics\"",[472,1713,494],{"class":486},[472,1715,1716],{"class":490}," fontsize",[472,1718,501],{"class":500},[472,1720,1721],{"class":504},"25",[472,1723,951],{"class":486},[472,1725,1726,1728,1730,1732,1734,1736],{"class":474,"line":752},[472,1727,1502],{"class":519},[472,1729,184],{"class":486},[472,1731,1507],{"class":549},[472,1733,487],{"class":486},[472,1735,1512],{"class":536},[472,1737,951],{"class":486},[472,1739,1740],{"class":474,"line":763},[472,1741,624],{"emptyLinePlaceholder":423},[472,1743,1744],{"class":474,"line":804},[472,1745,1746],{"class":513},"    # Rating distribution (ax1)\n",[472,1748,1749,1751,1753,1756,1758,1761,1763,1765,1767,1770,1772,1775,1777,1780,1782,1784,1786,1789,1791,1793,1796,1798,1801],{"class":474,"line":830},[472,1750,1502],{"class":519},[472,1752,184],{"class":486},[472,1754,1755],{"class":549},"histplot",[472,1757,487],{"class":486},[472,1759,1760],{"class":490},"ax",[472,1762,501],{"class":500},[472,1764,1625],{"class":519},[472,1766,494],{"class":486},[472,1768,1769],{"class":490}," data",[472,1771,501],{"class":500},[472,1773,1774],{"class":519},"combined_rating_range",[472,1776,494],{"class":486},[472,1778,1779],{"class":490}," kde",[472,1781,501],{"class":500},[472,1783,1067],{"class":504},[472,1785,494],{"class":486},[472,1787,1788],{"class":490}," kde_kws",[472,1790,501],{"class":500},[472,1792,772],{"class":486},[472,1794,1795],{"class":536},"'bw_adjust'",[472,1797,320],{"class":486},[472,1799,1800],{"class":504}," 4",[472,1802,1803],{"class":486},"})\n",[472,1805,1806,1809,1811,1814,1816,1819,1821,1823,1825,1828],{"class":474,"line":836},[472,1807,1808],{"class":519},"    ax1",[472,1810,184],{"class":486},[472,1812,1813],{"class":549},"set_title",[472,1815,487],{"class":486},[472,1817,1818],{"class":536},"'Rating'",[472,1820,494],{"class":486},[472,1822,1716],{"class":490},[472,1824,501],{"class":500},[472,1826,1827],{"class":504},"20",[472,1829,951],{"class":486},[472,1831,1832,1834,1836,1839,1841,1843,1845,1848,1850,1853,1855,1858,1860,1863,1865,1868,1870,1873],{"class":474,"line":881},[472,1833,1808],{"class":519},[472,1835,184],{"class":486},[472,1837,1838],{"class":549},"set_xticklabels",[472,1840,487],{"class":486},[472,1842,948],{"class":519},[472,1844,494],{"class":486},[472,1846,1847],{"class":490}," rotation",[472,1849,501],{"class":500},[472,1851,1852],{"class":504},"60",[472,1854,494],{"class":486},[472,1856,1857],{"class":490}," ha",[472,1859,501],{"class":500},[472,1861,1862],{"class":536},"'right'",[472,1864,494],{"class":486},[472,1866,1867],{"class":490}," rotation_mode",[472,1869,501],{"class":500},[472,1871,1872],{"class":536},"'anchor'",[472,1874,951],{"class":486},[472,1876,1877,1879,1881,1884,1886,1889],{"class":474,"line":886},[472,1878,1808],{"class":519},[472,1880,184],{"class":486},[472,1882,1883],{"class":549},"set_ylabel",[472,1885,487],{"class":486},[472,1887,1888],{"class":536},"''",[472,1890,951],{"class":486},[472,1892,1893,1895,1897,1900,1902,1904],{"class":474,"line":892},[472,1894,1808],{"class":519},[472,1896,184],{"class":486},[472,1898,1899],{"class":549},"set_axisbelow",[472,1901,487],{"class":486},[472,1903,1067],{"class":504},[472,1905,951],{"class":486},[472,1907,1908],{"class":474,"line":954},[472,1909,624],{"emptyLinePlaceholder":423},[472,1911,1912],{"class":474,"line":1008},[472,1913,1914],{"class":513},"    # Game terminations (ax2)\n",[472,1916,1917,1919,1921,1923,1925,1927,1929,1932,1934,1936,1938,1940,1942,1945,1947,1950],{"class":474,"line":1013},[472,1918,1502],{"class":519},[472,1920,184],{"class":486},[472,1922,1755],{"class":549},[472,1924,487],{"class":486},[472,1926,1760],{"class":490},[472,1928,501],{"class":500},[472,1930,1931],{"class":519},"ax2",[472,1933,494],{"class":486},[472,1935,1769],{"class":490},[472,1937,501],{"class":500},[472,1939,491],{"class":519},[472,1941,494],{"class":486},[472,1943,1944],{"class":490}," x",[472,1946,501],{"class":500},[472,1948,1949],{"class":536},"'Termination'",[472,1951,951],{"class":486},[472,1953,1954,1957,1959,1961,1963,1966,1968,1970,1972,1974],{"class":474,"line":1019},[472,1955,1956],{"class":519},"    ax2",[472,1958,184],{"class":486},[472,1960,1813],{"class":549},[472,1962,487],{"class":486},[472,1964,1965],{"class":536},"'Game termination'",[472,1967,494],{"class":486},[472,1969,1716],{"class":490},[472,1971,501],{"class":500},[472,1973,1827],{"class":504},[472,1975,951],{"class":486},[472,1977,1978,1980,1982,1985,1987,1989],{"class":474,"line":1072},[472,1979,1956],{"class":519},[472,1981,184],{"class":486},[472,1983,1984],{"class":549},"set_xlabel",[472,1986,487],{"class":486},[472,1988,1888],{"class":536},[472,1990,951],{"class":486},[472,1992,1993,1995,1997,1999,2001,2003],{"class":474,"line":1077},[472,1994,1956],{"class":519},[472,1996,184],{"class":486},[472,1998,1883],{"class":549},[472,2000,487],{"class":486},[472,2002,1888],{"class":536},[472,2004,951],{"class":486},[472,2006,2008],{"class":474,"line":2007},28,[472,2009,624],{"emptyLinePlaceholder":423},[472,2011,2013],{"class":474,"line":2012},29,[472,2014,2015],{"class":513},"    # Game length (ax3)\n",[472,2017,2019,2021,2023,2025,2027,2029,2031,2033,2035,2037,2039,2042,2044,2046,2048,2051,2053,2056,2058,2061,2063,2065,2067,2069],{"class":474,"line":2018},30,[472,2020,1502],{"class":519},[472,2022,184],{"class":486},[472,2024,1755],{"class":549},[472,2026,487],{"class":486},[472,2028,1760],{"class":490},[472,2030,501],{"class":500},[472,2032,1638],{"class":519},[472,2034,494],{"class":486},[472,2036,1769],{"class":490},[472,2038,501],{"class":500},[472,2040,2041],{"class":519},"game_length_df",[472,2043,494],{"class":486},[472,2045,1944],{"class":490},[472,2047,501],{"class":500},[472,2049,2050],{"class":536},"'game_length'",[472,2052,494],{"class":486},[472,2054,2055],{"class":490}," binwidth",[472,2057,501],{"class":500},[472,2059,2060],{"class":504},"5",[472,2062,494],{"class":486},[472,2064,1779],{"class":490},[472,2066,501],{"class":500},[472,2068,1067],{"class":504},[472,2070,951],{"class":486},[472,2072,2074,2077,2079,2081,2083,2086,2088,2090,2092,2094],{"class":474,"line":2073},31,[472,2075,2076],{"class":519},"    ax3",[472,2078,184],{"class":486},[472,2080,1813],{"class":549},[472,2082,487],{"class":486},[472,2084,2085],{"class":536},"'Game length'",[472,2087,494],{"class":486},[472,2089,1716],{"class":490},[472,2091,501],{"class":500},[472,2093,1827],{"class":504},[472,2095,951],{"class":486},[472,2097,2099,2101,2103,2105,2107,2109],{"class":474,"line":2098},32,[472,2100,2076],{"class":519},[472,2102,184],{"class":486},[472,2104,1984],{"class":549},[472,2106,487],{"class":486},[472,2108,1888],{"class":536},[472,2110,951],{"class":486},[472,2112,2114,2116,2118,2120,2122,2124],{"class":474,"line":2113},33,[472,2115,2076],{"class":519},[472,2117,184],{"class":486},[472,2119,1883],{"class":549},[472,2121,487],{"class":486},[472,2123,1888],{"class":536},[472,2125,951],{"class":486},[472,2127,2129],{"class":474,"line":2128},34,[472,2130,624],{"emptyLinePlaceholder":423},[472,2132,2134],{"class":474,"line":2133},35,[472,2135,2136],{"class":513},"    # Game mode (ax4)\n",[472,2138,2140,2142,2144,2146,2148,2150,2152,2155,2157,2159,2161,2163,2165,2167,2169,2172],{"class":474,"line":2139},36,[472,2141,1502],{"class":519},[472,2143,184],{"class":486},[472,2145,1755],{"class":549},[472,2147,487],{"class":486},[472,2149,1760],{"class":490},[472,2151,501],{"class":500},[472,2153,2154],{"class":519},"ax4",[472,2156,494],{"class":486},[472,2158,1769],{"class":490},[472,2160,501],{"class":500},[472,2162,491],{"class":519},[472,2164,494],{"class":486},[472,2166,1944],{"class":490},[472,2168,501],{"class":500},[472,2170,2171],{"class":536},"'GameMode'",[472,2173,951],{"class":486},[472,2175,2177,2180,2182,2184,2186,2189,2191,2193,2195,2197],{"class":474,"line":2176},37,[472,2178,2179],{"class":519},"    ax4",[472,2181,184],{"class":486},[472,2183,1813],{"class":549},[472,2185,487],{"class":486},[472,2187,2188],{"class":536},"'Game mode'",[472,2190,494],{"class":486},[472,2192,1716],{"class":490},[472,2194,501],{"class":500},[472,2196,1827],{"class":504},[472,2198,951],{"class":486},[472,2200,2202,2204,2206,2208,2210,2212],{"class":474,"line":2201},38,[472,2203,2179],{"class":519},[472,2205,184],{"class":486},[472,2207,1984],{"class":549},[472,2209,487],{"class":486},[472,2211,1888],{"class":536},[472,2213,951],{"class":486},[472,2215,2217,2219,2221,2223,2225,2227],{"class":474,"line":2216},39,[472,2218,2179],{"class":519},[472,2220,184],{"class":486},[472,2222,1883],{"class":549},[472,2224,487],{"class":486},[472,2226,1888],{"class":536},[472,2228,951],{"class":486},[472,2230,2232],{"class":474,"line":2231},40,[472,2233,624],{"emptyLinePlaceholder":423},[472,2235,2237],{"class":474,"line":2236},41,[472,2238,2239],{"class":513},"    # Game result (ax5)\n",[472,2241,2243,2245,2247,2249,2251,2253,2255,2257,2259,2261,2263,2265,2267,2269,2271,2274],{"class":474,"line":2242},42,[472,2244,1502],{"class":519},[472,2246,184],{"class":486},[472,2248,1755],{"class":549},[472,2250,487],{"class":486},[472,2252,1760],{"class":490},[472,2254,501],{"class":500},[472,2256,1650],{"class":519},[472,2258,494],{"class":486},[472,2260,1769],{"class":490},[472,2262,501],{"class":500},[472,2264,491],{"class":519},[472,2266,494],{"class":486},[472,2268,1944],{"class":490},[472,2270,501],{"class":500},[472,2272,2273],{"class":536},"'Result'",[472,2275,951],{"class":486},[472,2277,2279,2282,2284,2286,2288,2291,2293,2295,2297,2299],{"class":474,"line":2278},43,[472,2280,2281],{"class":519},"    ax5",[472,2283,184],{"class":486},[472,2285,1813],{"class":549},[472,2287,487],{"class":486},[472,2289,2290],{"class":536},"'Game result'",[472,2292,494],{"class":486},[472,2294,1716],{"class":490},[472,2296,501],{"class":500},[472,2298,1827],{"class":504},[472,2300,951],{"class":486},[472,2302,2304,2306,2308,2310,2312,2314],{"class":474,"line":2303},44,[472,2305,2281],{"class":519},[472,2307,184],{"class":486},[472,2309,1984],{"class":549},[472,2311,487],{"class":486},[472,2313,1888],{"class":536},[472,2315,951],{"class":486},[472,2317,2319,2321,2323,2325,2327,2329],{"class":474,"line":2318},45,[472,2320,2281],{"class":519},[472,2322,184],{"class":486},[472,2324,1883],{"class":549},[472,2326,487],{"class":486},[472,2328,1888],{"class":536},[472,2330,951],{"class":486},[472,2332,2334],{"class":474,"line":2333},46,[472,2335,624],{"emptyLinePlaceholder":423},[472,2337,2339],{"class":474,"line":2338},47,[472,2340,2341],{"class":513},"    # Increment counts (ax6)\n",[472,2343,2345,2348,2350,2352,2354,2356,2358,2360,2362,2365,2367,2370,2372,2375,2377],{"class":474,"line":2344},48,[472,2346,2347],{"class":519},"    increment_order ",[472,2349,501],{"class":500},[472,2351,556],{"class":490},[472,2353,533],{"class":486},[472,2355,537],{"class":536},[472,2357,1156],{"class":540},[472,2359,537],{"class":536},[472,2361,546],{"class":486},[472,2363,2364],{"class":549},"value_counts",[472,2366,487],{"class":486},[472,2368,2369],{"class":490},"ascending",[472,2371,501],{"class":500},[472,2373,2374],{"class":504},"False",[472,2376,1189],{"class":486},[472,2378,2379],{"class":519},"index\n",[472,2381,2383,2385,2387,2390,2392,2394,2396,2399,2401,2403,2405,2407,2409,2411,2413,2416,2418,2421,2423,2426],{"class":474,"line":2382},49,[472,2384,1502],{"class":519},[472,2386,184],{"class":486},[472,2388,2389],{"class":549},"countplot",[472,2391,487],{"class":486},[472,2393,1760],{"class":490},[472,2395,501],{"class":500},[472,2397,2398],{"class":519},"ax6",[472,2400,494],{"class":486},[472,2402,1769],{"class":490},[472,2404,501],{"class":500},[472,2406,491],{"class":519},[472,2408,494],{"class":486},[472,2410,1944],{"class":490},[472,2412,501],{"class":500},[472,2414,2415],{"class":536},"'Increment'",[472,2417,494],{"class":486},[472,2419,2420],{"class":490}," order",[472,2422,501],{"class":500},[472,2424,2425],{"class":519},"increment_order",[472,2427,951],{"class":486},[472,2429,2431,2434,2436,2438,2440,2442,2444,2446,2448,2450],{"class":474,"line":2430},50,[472,2432,2433],{"class":519},"    ax6",[472,2435,184],{"class":486},[472,2437,1813],{"class":549},[472,2439,487],{"class":486},[472,2441,2415],{"class":536},[472,2443,494],{"class":486},[472,2445,1716],{"class":490},[472,2447,501],{"class":500},[472,2449,1827],{"class":504},[472,2451,951],{"class":486},[472,2453,2455,2457,2459,2461,2463,2465],{"class":474,"line":2454},51,[472,2456,2433],{"class":519},[472,2458,184],{"class":486},[472,2460,1984],{"class":549},[472,2462,487],{"class":486},[472,2464,1888],{"class":536},[472,2466,951],{"class":486},[472,2468,2470,2472,2474,2476,2478,2480],{"class":474,"line":2469},52,[472,2471,2433],{"class":519},[472,2473,184],{"class":486},[472,2475,1883],{"class":549},[472,2477,487],{"class":486},[472,2479,1888],{"class":536},[472,2481,951],{"class":486},[472,2483,2485],{"class":474,"line":2484},53,[472,2486,624],{"emptyLinePlaceholder":423},[472,2488,2490,2493,2495,2498,2500,2503,2505,2507,2510,2512,2515,2517,2519,2521,2524],{"class":474,"line":2489},54,[472,2491,2492],{"class":519},"    plt",[472,2494,184],{"class":486},[472,2496,2497],{"class":549},"tight_layout",[472,2499,487],{"class":486},[472,2501,2502],{"class":490},"rect",[472,2504,501],{"class":500},[472,2506,533],{"class":486},[472,2508,2509],{"class":504},"0",[472,2511,494],{"class":486},[472,2513,2514],{"class":504}," 0",[472,2516,494],{"class":486},[472,2518,682],{"class":504},[472,2520,494],{"class":486},[472,2522,2523],{"class":504}," 0.96",[472,2525,2526],{"class":486},"])\n",[472,2528,2530,2533,2535],{"class":474,"line":2529},55,[472,2531,2532],{"class":478},"    if",[472,2534,1485],{"class":519},[472,2536,2537],{"class":486},":\n",[472,2539,2541,2544,2546,2549],{"class":474,"line":2540},56,[472,2542,2543],{"class":519},"        plt",[472,2545,184],{"class":486},[472,2547,2548],{"class":549},"savefig",[472,2550,2551],{"class":486},"(\n",[472,2553,2555,2558],{"class":474,"line":2554},57,[472,2556,2557],{"class":519},"            file_name",[472,2559,2560],{"class":486},",\n",[472,2562,2564,2567,2569,2572],{"class":474,"line":2563},58,[472,2565,2566],{"class":490},"            dpi",[472,2568,501],{"class":500},[472,2570,2571],{"class":504},"300",[472,2573,2560],{"class":486},[472,2575,2577,2580,2582,2585],{"class":474,"line":2576},59,[472,2578,2579],{"class":490},"            bbox_inches",[472,2581,501],{"class":500},[472,2583,2584],{"class":536},"'tight'",[472,2586,2560],{"class":486},[472,2588,2590,2593,2595,2597],{"class":474,"line":2589},60,[472,2591,2592],{"class":490},"            transparent",[472,2594,501],{"class":500},[472,2596,1067],{"class":504},[472,2598,2560],{"class":486},[472,2600,2602],{"class":474,"line":2601},61,[472,2603,2604],{"class":486},"        )\n",[472,2606,2608,2610,2612,2615],{"class":474,"line":2607},62,[472,2609,2492],{"class":519},[472,2611,184],{"class":486},[472,2613,2614],{"class":549},"show",[472,2616,1341],{"class":486},[2618,2619,2620],"style",{},"html pre.shiki code .sTQ8l, html code.shiki .sTQ8l{--shiki-light:#8839EF;--shiki-default:#8839EF;--shiki-dark:#C6A0F6}html pre.shiki code .sZJYN, html code.shiki .sZJYN{--shiki-light:#1E66F5;--shiki-light-font-style:italic;--shiki-default:#1E66F5;--shiki-default-font-style:italic;--shiki-dark:#8AADF4;--shiki-dark-font-style:italic}html pre.shiki code .shMcR, html code.shiki .shMcR{--shiki-light:#7C7F93;--shiki-default:#7C7F93;--shiki-dark:#939AB7}html pre.shiki code .s1dUP, html code.shiki .s1dUP{--shiki-light:#E64553;--shiki-light-font-style:italic;--shiki-default:#E64553;--shiki-default-font-style:italic;--shiki-dark:#EE99A0;--shiki-dark-font-style:italic}html pre.shiki code .saHHS, html code.shiki .saHHS{--shiki-light:#179299;--shiki-default:#179299;--shiki-dark:#8BD5CA}html pre.shiki code .sI2Su, html code.shiki .sI2Su{--shiki-light:#FE640B;--shiki-default:#FE640B;--shiki-dark:#F5A97F}html pre.shiki code .se-gO, html code.shiki .se-gO{--shiki-light:#7C7F93;--shiki-light-font-style:italic;--shiki-default:#7C7F93;--shiki-default-font-style:italic;--shiki-dark:#939AB7;--shiki-dark-font-style:italic}html pre.shiki code .swLP3, html code.shiki .swLP3{--shiki-light:#4C4F69;--shiki-default:#4C4F69;--shiki-dark:#CAD3F5}html pre.shiki code .sV1I6, html code.shiki .sV1I6{--shiki-light:#FE640B;--shiki-light-font-style:italic;--shiki-default:#FE640B;--shiki-default-font-style:italic;--shiki-dark:#F5A97F;--shiki-dark-font-style:italic}html pre.shiki code .sPevk, html code.shiki .sPevk{--shiki-light:#40A02B;--shiki-default:#40A02B;--shiki-dark:#A6DA95}html pre.shiki code .s3e4v, html code.shiki .s3e4v{--shiki-light:#40A02B;--shiki-light-font-style:italic;--shiki-default:#40A02B;--shiki-default-font-style:italic;--shiki-dark:#A6DA95;--shiki-dark-font-style:italic}html pre.shiki code .sBYUN, html code.shiki .sBYUN{--shiki-light:#1E66F5;--shiki-default:#1E66F5;--shiki-dark:#8AADF4}html pre.shiki code .sdQ9k, html code.shiki .sdQ9k{--shiki-light:#8839EF;--shiki-light-font-style:italic;--shiki-default:#8839EF;--shiki-default-font-style:italic;--shiki-dark:#C6A0F6;--shiki-dark-font-style:italic}html pre.shiki code .siCgW, html code.shiki .siCgW{--shiki-light:#EA76CB;--shiki-default:#EA76CB;--shiki-dark:#F5BDE6}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":407,"searchDepth":408,"depth":408,"links":2622},[],{},"/blog/chess-games/snippets/descriptive-stats",{"description":407},"blog/chess-games/snippets/descriptive-stats","cV0aer0dkNtfc0XNhiUtaCc9gXEfTUJaU7Z9Xt_HCUU",{"id":2629,"title":2630,"body":2631,"description":407,"extension":419,"language":422,"meta":3024,"name":422,"navigation":423,"path":3025,"seo":3026,"stem":3027,"__hash__":3028},"snippet/blog/chess-games/snippets/cleaning.md","Cleaning",{"type":25,"value":2632,"toc":3022},[2633,3019],[463,2634,2637],{"className":465,"code":2635,"filename":2636,"language":467,"meta":407,"style":407},"df_clean = df[~df['Termination'].isin([\"Abandoned\", \"Rules infraction\"])]\ndf_clean = df_clean[~df_clean['GameMode'].isin(['Bullet', 'UltraBullet'])]\ndf_clean = df_clean[(df_clean['WhiteElo'] \u003C= 2500) & (df_clean['BlackElo'] \u003C= 2500)]\ndf_clean = df_clean[df_clean['Increment'].isin([0, 15, 3, 2, 1, 5, 10])]\ndf_clean = df_clean[(df_clean['WhiteRatingDiff'] \u003C= 200) & (df_clean['WhiteRatingDiff'] >= -200)]\n\nfor col_prefix in ['Eval_ply_', 'Move_ply_', 'Clock_ply_']:\n    columns_to_drop = [f'{col_prefix}{i}' for i in range(151, 201)]\n    df_clean = df_clean.drop(columns=columns_to_drop)\n","cleaning.py",[469,2638,2639,2692,2741,2795,2853,2910,2914,2941,2993],{"__ignoreMap":407},[472,2640,2641,2644,2646,2648,2650,2653,2655,2657,2659,2662,2664,2666,2669,2671,2674,2677,2679,2681,2684,2687,2689],{"class":474,"line":475},[472,2642,2643],{"class":519},"df_clean ",[472,2645,501],{"class":500},[472,2647,556],{"class":490},[472,2649,533],{"class":486},[472,2651,2652],{"class":500},"~",[472,2654,491],{"class":490},[472,2656,533],{"class":486},[472,2658,537],{"class":536},[472,2660,2661],{"class":540},"Termination",[472,2663,537],{"class":536},[472,2665,546],{"class":486},[472,2667,2668],{"class":482},"isin",[472,2670,1034],{"class":486},[472,2672,2673],{"class":536},"\"",[472,2675,2676],{"class":540},"Abandoned",[472,2678,2673],{"class":536},[472,2680,494],{"class":486},[472,2682,2683],{"class":536}," \"",[472,2685,2686],{"class":540},"Rules infraction",[472,2688,2673],{"class":536},[472,2690,2691],{"class":486},"])]\n",[472,2693,2694,2696,2698,2701,2703,2705,2708,2710,2712,2714,2716,2718,2720,2722,2724,2727,2729,2731,2734,2737,2739],{"class":474,"line":411},[472,2695,2643],{"class":519},[472,2697,501],{"class":500},[472,2699,2700],{"class":490}," df_clean",[472,2702,533],{"class":486},[472,2704,2652],{"class":500},[472,2706,2707],{"class":490},"df_clean",[472,2709,533],{"class":486},[472,2711,537],{"class":536},[472,2713,1107],{"class":540},[472,2715,537],{"class":536},[472,2717,546],{"class":486},[472,2719,2668],{"class":482},[472,2721,1034],{"class":486},[472,2723,537],{"class":536},[472,2725,2726],{"class":540},"Bullet",[472,2728,537],{"class":536},[472,2730,494],{"class":486},[472,2732,2733],{"class":536}," '",[472,2735,2736],{"class":540},"UltraBullet",[472,2738,537],{"class":536},[472,2740,2691],{"class":486},[472,2742,2743,2745,2747,2749,2752,2754,2756,2758,2760,2762,2764,2767,2770,2772,2775,2777,2779,2781,2783,2785,2787,2789,2791,2793],{"class":474,"line":408},[472,2744,2643],{"class":519},[472,2746,501],{"class":500},[472,2748,2700],{"class":490},[472,2750,2751],{"class":486},"[(",[472,2753,2707],{"class":490},[472,2755,533],{"class":486},[472,2757,537],{"class":536},[472,2759,541],{"class":540},[472,2761,537],{"class":536},[472,2763,848],{"class":486},[472,2765,2766],{"class":500}," \u003C=",[472,2768,2769],{"class":525}," 2500",[472,2771,651],{"class":486},[472,2773,2774],{"class":500}," &",[472,2776,640],{"class":486},[472,2778,2707],{"class":490},[472,2780,533],{"class":486},[472,2782,537],{"class":536},[472,2784,563],{"class":540},[472,2786,537],{"class":536},[472,2788,848],{"class":486},[472,2790,2766],{"class":500},[472,2792,2769],{"class":525},[472,2794,1313],{"class":486},[472,2796,2797,2799,2801,2803,2805,2807,2809,2811,2813,2815,2817,2819,2821,2823,2825,2828,2830,2833,2835,2837,2839,2841,2843,2846,2848,2851],{"class":474,"line":575},[472,2798,2643],{"class":519},[472,2800,501],{"class":500},[472,2802,2700],{"class":490},[472,2804,533],{"class":486},[472,2806,2707],{"class":490},[472,2808,533],{"class":486},[472,2810,537],{"class":536},[472,2812,1156],{"class":540},[472,2814,537],{"class":536},[472,2816,546],{"class":486},[472,2818,2668],{"class":482},[472,2820,1034],{"class":486},[472,2822,2509],{"class":525},[472,2824,494],{"class":486},[472,2826,2827],{"class":525}," 15",[472,2829,494],{"class":486},[472,2831,2832],{"class":525}," 3",[472,2834,494],{"class":486},[472,2836,1678],{"class":525},[472,2838,494],{"class":486},[472,2840,682],{"class":525},[472,2842,494],{"class":486},[472,2844,2845],{"class":525}," 5",[472,2847,494],{"class":486},[472,2849,2850],{"class":525}," 10",[472,2852,2691],{"class":486},[472,2854,2855,2857,2859,2861,2863,2865,2867,2869,2872,2874,2876,2878,2881,2883,2885,2887,2889,2891,2893,2895,2897,2899,2902,2905,2908],{"class":474,"line":621},[472,2856,2643],{"class":519},[472,2858,501],{"class":500},[472,2860,2700],{"class":490},[472,2862,2751],{"class":486},[472,2864,2707],{"class":490},[472,2866,533],{"class":486},[472,2868,537],{"class":536},[472,2870,2871],{"class":540},"WhiteRatingDiff",[472,2873,537],{"class":536},[472,2875,848],{"class":486},[472,2877,2766],{"class":500},[472,2879,2880],{"class":525}," 200",[472,2882,651],{"class":486},[472,2884,2774],{"class":500},[472,2886,640],{"class":486},[472,2888,2707],{"class":490},[472,2890,533],{"class":486},[472,2892,537],{"class":536},[472,2894,2871],{"class":540},[472,2896,537],{"class":536},[472,2898,848],{"class":486},[472,2900,2901],{"class":500}," >=",[472,2903,2904],{"class":500}," -",[472,2906,2907],{"class":525},"200",[472,2909,1313],{"class":486},[472,2911,2912],{"class":474,"line":627},[472,2913,624],{"emptyLinePlaceholder":423},[472,2915,2916,2918,2921,2923,2925,2928,2930,2933,2935,2938],{"class":474,"line":633},[472,2917,1282],{"class":478},[472,2919,2920],{"class":519}," col_prefix ",[472,2922,813],{"class":478},[472,2924,1276],{"class":486},[472,2926,2927],{"class":536},"'Eval_ply_'",[472,2929,494],{"class":486},[472,2931,2932],{"class":536}," 'Move_ply_'",[472,2934,494],{"class":486},[472,2936,2937],{"class":536}," 'Clock_ply_'",[472,2939,2940],{"class":486},"]:\n",[472,2942,2943,2946,2948,2950,2953,2955,2957,2960,2963,2966,2968,2970,2973,2976,2978,2981,2983,2986,2988,2991],{"class":474,"line":660},[472,2944,2945],{"class":519},"    columns_to_drop ",[472,2947,501],{"class":500},[472,2949,1276],{"class":486},[472,2951,2952],{"class":540},"f",[472,2954,537],{"class":536},[472,2956,772],{"class":771},[472,2958,2959],{"class":519},"col_prefix",[472,2961,2962],{"class":771},"}{",[472,2964,2965],{"class":519},"i",[472,2967,778],{"class":771},[472,2969,537],{"class":536},[472,2971,2972],{"class":478}," for",[472,2974,2975],{"class":519}," i ",[472,2977,813],{"class":478},[472,2979,2980],{"class":525}," range",[472,2982,487],{"class":486},[472,2984,2985],{"class":504},"151",[472,2987,494],{"class":486},[472,2989,2990],{"class":504}," 201",[472,2992,1313],{"class":486},[472,2994,2995,2998,3000,3002,3004,3007,3009,3012,3014,3017],{"class":474,"line":691},[472,2996,2997],{"class":519},"    df_clean ",[472,2999,501],{"class":500},[472,3001,2700],{"class":519},[472,3003,184],{"class":486},[472,3005,3006],{"class":549},"drop",[472,3008,487],{"class":486},[472,3010,3011],{"class":490},"columns",[472,3013,501],{"class":500},[472,3015,3016],{"class":519},"columns_to_drop",[472,3018,951],{"class":486},[2618,3020,3021],{},"html pre.shiki code .swLP3, html code.shiki .swLP3{--shiki-light:#4C4F69;--shiki-default:#4C4F69;--shiki-dark:#CAD3F5}html pre.shiki code .saHHS, html code.shiki .saHHS{--shiki-light:#179299;--shiki-default:#179299;--shiki-dark:#8BD5CA}html pre.shiki code .s1dUP, html code.shiki .s1dUP{--shiki-light:#E64553;--shiki-light-font-style:italic;--shiki-default:#E64553;--shiki-default-font-style:italic;--shiki-dark:#EE99A0;--shiki-dark-font-style:italic}html pre.shiki code .shMcR, html code.shiki .shMcR{--shiki-light:#7C7F93;--shiki-default:#7C7F93;--shiki-dark:#939AB7}html pre.shiki code .sPevk, html code.shiki .sPevk{--shiki-light:#40A02B;--shiki-default:#40A02B;--shiki-dark:#A6DA95}html pre.shiki code .s3e4v, html code.shiki .s3e4v{--shiki-light:#40A02B;--shiki-light-font-style:italic;--shiki-default:#40A02B;--shiki-default-font-style:italic;--shiki-dark:#A6DA95;--shiki-dark-font-style:italic}html pre.shiki code .sZJYN, html code.shiki .sZJYN{--shiki-light:#1E66F5;--shiki-light-font-style:italic;--shiki-default:#1E66F5;--shiki-default-font-style:italic;--shiki-dark:#8AADF4;--shiki-dark-font-style:italic}html pre.shiki code .sV1I6, html code.shiki .sV1I6{--shiki-light:#FE640B;--shiki-light-font-style:italic;--shiki-default:#FE640B;--shiki-default-font-style:italic;--shiki-dark:#F5A97F;--shiki-dark-font-style:italic}html pre.shiki code .sTQ8l, html code.shiki .sTQ8l{--shiki-light:#8839EF;--shiki-default:#8839EF;--shiki-dark:#C6A0F6}html pre.shiki code .siCgW, html code.shiki .siCgW{--shiki-light:#EA76CB;--shiki-default:#EA76CB;--shiki-dark:#F5BDE6}html pre.shiki code .sI2Su, html code.shiki .sI2Su{--shiki-light:#FE640B;--shiki-default:#FE640B;--shiki-dark:#F5A97F}html pre.shiki code .sBYUN, html code.shiki .sBYUN{--shiki-light:#1E66F5;--shiki-default:#1E66F5;--shiki-dark:#8AADF4}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":407,"searchDepth":408,"depth":408,"links":3023},[],{},"/blog/chess-games/snippets/cleaning",{"description":407},"blog/chess-games/snippets/cleaning","q-WaQ0s-Zrgvzp0SXVt_hLcnyaY-dl5AW05pW1AJwvo",{"id":3030,"title":3031,"body":3032,"description":407,"extension":419,"language":422,"meta":3044,"name":422,"navigation":423,"path":3045,"seo":3046,"stem":3047,"__hash__":3048},"snippet/blog/chess-games/snippets/cleaning-output.md","Cleaning Output",{"type":25,"value":3033,"toc":3042},[3034],[463,3035,3040],{"className":3036,"code":3038,"filename":3039,"language":439,"meta":407},[3037],"language-text","Removed    17 Games with irregular Termination\nRemoved 43253 Bullet & UltraBullet games\nRemoved   310 Games with 2500 or higher ELO players\nRemoved  3503 Games with non-standard increments\nRemoved  4417 Games with RatingDiff of 200 or more\nRemoved    50 Columns for the last ply\n\nRemoved 47997 games in total\nRemaining games: 152003 from 200000 (76.00%)\nOld shape: (200000, 628)\nNew shape: (152003, 478)\n","Output",[469,3041,3038],{"__ignoreMap":407},{"title":407,"searchDepth":408,"depth":408,"links":3043},[],{},"/blog/chess-games/snippets/cleaning-output",{"description":407},"blog/chess-games/snippets/cleaning-output","PejrfUgzkYUNi-JRs1UYQFridZvAofD1X4cbR58LXGI",{"id":3050,"title":3051,"body":3052,"description":407,"extension":419,"language":422,"meta":4276,"name":422,"navigation":423,"path":4277,"seo":4278,"stem":4279,"__hash__":4280},"snippet/blog/chess-games/snippets/time-eval.md","Time Eval",{"type":25,"value":3053,"toc":4274},[3054,3350,3360,3494,3497,3704,3707,3907,3910,4271],[463,3055,3057],{"className":465,"code":3056,"language":467,"meta":407,"style":407},"# Extract the Eval_ply_x columns\neval_columns = [f'Eval_ply_{i}' for i in range(1, 151)]\ndf_eval = df_clean[eval_columns]\n\n# Extract the Clock_ply_x columns and convert to total seconds\nclock_columns = [f'Clock_ply_{i}' for i in range(1, 151)]\ndf_time = df_clean[clock_columns].apply(pd.to_timedelta)\ndf_time = df_time.map(lambda x: x.total_seconds() if pd.notna(x) else x)\n\n# Combine both DataFrames and add some relevant columns\ndf_combined = pd.concat([df_eval, df_time], axis=1)\ncolumns_to_add = ['Index', 'GameMode', 'Increment', 'IncrementCategory']\ndf_combined[columns_to_add] = df_clean[columns_to_add]\n",[469,3058,3059,3064,3105,3121,3125,3130,3170,3200,3257,3261,3266,3299,3328],{"__ignoreMap":407},[472,3060,3061],{"class":474,"line":475},[472,3062,3063],{"class":513},"# Extract the Eval_ply_x columns\n",[472,3065,3066,3069,3071,3073,3075,3078,3080,3082,3084,3086,3088,3090,3092,3094,3096,3098,3100,3103],{"class":474,"line":411},[472,3067,3068],{"class":519},"eval_columns ",[472,3070,501],{"class":500},[472,3072,1276],{"class":486},[472,3074,2952],{"class":540},[472,3076,3077],{"class":536},"'Eval_ply_",[472,3079,772],{"class":771},[472,3081,2965],{"class":519},[472,3083,778],{"class":771},[472,3085,537],{"class":536},[472,3087,2972],{"class":478},[472,3089,2975],{"class":519},[472,3091,813],{"class":478},[472,3093,2980],{"class":525},[472,3095,487],{"class":486},[472,3097,824],{"class":504},[472,3099,494],{"class":486},[472,3101,3102],{"class":504}," 151",[472,3104,1313],{"class":486},[472,3106,3107,3110,3112,3114,3116,3119],{"class":474,"line":408},[472,3108,3109],{"class":519},"df_eval ",[472,3111,501],{"class":500},[472,3113,2700],{"class":490},[472,3115,533],{"class":486},[472,3117,3118],{"class":490},"eval_columns",[472,3120,827],{"class":486},[472,3122,3123],{"class":474,"line":575},[472,3124,624],{"emptyLinePlaceholder":423},[472,3126,3127],{"class":474,"line":621},[472,3128,3129],{"class":513},"# Extract the Clock_ply_x columns and convert to total seconds\n",[472,3131,3132,3135,3137,3139,3141,3144,3146,3148,3150,3152,3154,3156,3158,3160,3162,3164,3166,3168],{"class":474,"line":627},[472,3133,3134],{"class":519},"clock_columns ",[472,3136,501],{"class":500},[472,3138,1276],{"class":486},[472,3140,2952],{"class":540},[472,3142,3143],{"class":536},"'Clock_ply_",[472,3145,772],{"class":771},[472,3147,2965],{"class":519},[472,3149,778],{"class":771},[472,3151,537],{"class":536},[472,3153,2972],{"class":478},[472,3155,2975],{"class":519},[472,3157,813],{"class":478},[472,3159,2980],{"class":525},[472,3161,487],{"class":486},[472,3163,824],{"class":504},[472,3165,494],{"class":486},[472,3167,3102],{"class":504},[472,3169,1313],{"class":486},[472,3171,3172,3175,3177,3179,3181,3184,3186,3189,3191,3193,3195,3198],{"class":474,"line":633},[472,3173,3174],{"class":519},"df_time ",[472,3176,501],{"class":500},[472,3178,2700],{"class":490},[472,3180,533],{"class":486},[472,3182,3183],{"class":490},"clock_columns",[472,3185,546],{"class":486},[472,3187,3188],{"class":549},"apply",[472,3190,487],{"class":486},[472,3192,1370],{"class":519},[472,3194,184],{"class":486},[472,3196,3197],{"class":519},"to_timedelta",[472,3199,951],{"class":486},[472,3201,3202,3204,3206,3209,3211,3214,3216,3219,3221,3223,3225,3227,3230,3233,3236,3238,3240,3243,3245,3248,3250,3253,3255],{"class":474,"line":660},[472,3203,3174],{"class":519},[472,3205,501],{"class":500},[472,3207,3208],{"class":519}," df_time",[472,3210,184],{"class":486},[472,3212,3213],{"class":549},"map",[472,3215,487],{"class":486},[472,3217,3218],{"class":478},"lambda",[472,3220,1944],{"class":490},[472,3222,320],{"class":486},[472,3224,1944],{"class":519},[472,3226,184],{"class":486},[472,3228,3229],{"class":549},"total_seconds",[472,3231,3232],{"class":486},"()",[472,3234,3235],{"class":478}," if",[472,3237,911],{"class":519},[472,3239,184],{"class":486},[472,3241,3242],{"class":549},"notna",[472,3244,487],{"class":486},[472,3246,3247],{"class":519},"x",[472,3249,651],{"class":486},[472,3251,3252],{"class":478}," else",[472,3254,1944],{"class":519},[472,3256,951],{"class":486},[472,3258,3259],{"class":474,"line":691},[472,3260,624],{"emptyLinePlaceholder":423},[472,3262,3263],{"class":474,"line":696},[472,3264,3265],{"class":513},"# Combine both DataFrames and add some relevant columns\n",[472,3267,3268,3271,3273,3275,3277,3279,3281,3284,3286,3288,3290,3293,3295,3297],{"class":474,"line":702},[472,3269,3270],{"class":519},"df_combined ",[472,3272,501],{"class":500},[472,3274,911],{"class":519},[472,3276,184],{"class":486},[472,3278,1031],{"class":549},[472,3280,1034],{"class":486},[472,3282,3283],{"class":519},"df_eval",[472,3285,494],{"class":486},[472,3287,3208],{"class":519},[472,3289,931],{"class":486},[472,3291,3292],{"class":490}," axis",[472,3294,501],{"class":500},[472,3296,824],{"class":504},[472,3298,951],{"class":486},[472,3300,3301,3304,3306,3308,3311,3313,3316,3318,3321,3323,3326],{"class":474,"line":741},[472,3302,3303],{"class":519},"columns_to_add ",[472,3305,501],{"class":500},[472,3307,1276],{"class":486},[472,3309,3310],{"class":536},"'Index'",[472,3312,494],{"class":486},[472,3314,3315],{"class":536}," 'GameMode'",[472,3317,494],{"class":486},[472,3319,3320],{"class":536}," 'Increment'",[472,3322,494],{"class":486},[472,3324,3325],{"class":536}," 'IncrementCategory'",[472,3327,827],{"class":486},[472,3329,3330,3333,3335,3338,3340,3342,3344,3346,3348],{"class":474,"line":746},[472,3331,3332],{"class":490},"df_combined",[472,3334,533],{"class":486},[472,3336,3337],{"class":490},"columns_to_add",[472,3339,848],{"class":486},[472,3341,851],{"class":500},[472,3343,2700],{"class":490},[472,3345,533],{"class":486},[472,3347,3337],{"class":490},[472,3349,827],{"class":486},[33,3351,3352,3353,3356,3357,3359],{},"When the computer sees a ",[86,3354,3355],{},"forced mate sequence",", it will give the number of moves until mate, with a hashtag in front of it.\nLater on in the limitations I will talk more about how this poses some problems for our analysis.\nSince there is no way to convert this into a numerical value without choosing an arbitrary number,\nour function will skip over moves that contain a forced mate.\nTo do this, we convert these to ",[469,3358,1490],{}," values, and then skip over those later on in the function.",[463,3361,3363],{"className":465,"code":3362,"language":467,"meta":407,"style":407},"def eval_conversion(eval_value):\n    if pd.isnull(eval_value):\n        return None\n    eval_str = str(eval_value)\n    if '#' in eval_str:      \n        return None\n    try:                     \n        return float(eval_str)          \n    except (ValueError, TypeError):\n        return None\n",[469,3364,3365,3379,3396,3404,3420,3438,3444,3454,3471,3488],{"__ignoreMap":407},[472,3366,3367,3369,3372,3374,3377],{"class":474,"line":475},[472,3368,479],{"class":478},[472,3370,3371],{"class":482}," eval_conversion",[472,3373,487],{"class":486},[472,3375,3376],{"class":490},"eval_value",[472,3378,508],{"class":486},[472,3380,3381,3383,3385,3387,3390,3392,3394],{"class":474,"line":411},[472,3382,2532],{"class":478},[472,3384,911],{"class":519},[472,3386,184],{"class":486},[472,3388,3389],{"class":549},"isnull",[472,3391,487],{"class":486},[472,3393,3376],{"class":519},[472,3395,508],{"class":486},[472,3397,3398,3401],{"class":474,"line":408},[472,3399,3400],{"class":478},"        return",[472,3402,3403],{"class":504}," None\n",[472,3405,3406,3409,3411,3414,3416,3418],{"class":474,"line":575},[472,3407,3408],{"class":519},"    eval_str ",[472,3410,501],{"class":500},[472,3412,3413],{"class":710}," str",[472,3415,487],{"class":486},[472,3417,3376],{"class":519},[472,3419,951],{"class":486},[472,3421,3422,3424,3427,3430,3433,3435],{"class":474,"line":621},[472,3423,2532],{"class":478},[472,3425,3426],{"class":536}," '#'",[472,3428,3429],{"class":478}," in",[472,3431,3432],{"class":519}," eval_str",[472,3434,320],{"class":486},[472,3436,3437],{"class":519},"      \n",[472,3439,3440,3442],{"class":474,"line":627},[472,3441,3400],{"class":478},[472,3443,3403],{"class":504},[472,3445,3446,3449,3451],{"class":474,"line":633},[472,3447,3448],{"class":478},"    try",[472,3450,320],{"class":486},[472,3452,3453],{"class":519},"                     \n",[472,3455,3456,3458,3461,3463,3466,3468],{"class":474,"line":660},[472,3457,3400],{"class":478},[472,3459,3460],{"class":710}," float",[472,3462,487],{"class":486},[472,3464,3465],{"class":519},"eval_str",[472,3467,651],{"class":486},[472,3469,3470],{"class":519},"          \n",[472,3472,3473,3476,3478,3481,3483,3486],{"class":474,"line":691},[472,3474,3475],{"class":478},"    except",[472,3477,640],{"class":486},[472,3479,3480],{"class":525},"ValueError",[472,3482,494],{"class":486},[472,3484,3485],{"class":525}," TypeError",[472,3487,508],{"class":486},[472,3489,3490,3492],{"class":474,"line":696},[472,3491,3400],{"class":478},[472,3493,3403],{"class":504},[33,3495,3496],{},"We need to loop over each game, and within each game over each move. The move data will be appended to a list at the end of each loop.",[463,3498,3500],{"className":465,"code":3499,"language":467,"meta":407,"style":407},"all_moves = []\n\nfor idx, row in df.iterrows():              \n    # Make sure we always have a move to compare to (+1 because range is non-inclusive)\n    for move_num in range(1, max_ply - 2 + 1):\n        # Determine the color to see if we need to multiply the evaluation by -1\n        color = 'white' if move_num % 2 == 1 else 'black'\n        # Column names for current and next move\n        curr_time_col = f'Clock_ply_{move_num}'\n        next_time_col = f'Clock_ply_{move_num + 2}'\n        curr_eval_col = f'Eval_ply_{move_num}'\n        next_eval_col = f'Eval_ply_{move_num + 2}'\n",[469,3501,3502,3512,3516,3543,3548,3579,3584,3613,3618,3638,3662,3681],{"__ignoreMap":407},[472,3503,3504,3507,3509],{"class":474,"line":475},[472,3505,3506],{"class":519},"all_moves ",[472,3508,501],{"class":500},[472,3510,3511],{"class":486}," []\n",[472,3513,3514],{"class":474,"line":411},[472,3515,624],{"emptyLinePlaceholder":423},[472,3517,3518,3520,3523,3525,3528,3530,3532,3534,3537,3540],{"class":474,"line":408},[472,3519,1282],{"class":478},[472,3521,3522],{"class":519}," idx",[472,3524,494],{"class":486},[472,3526,3527],{"class":519}," row ",[472,3529,813],{"class":478},[472,3531,556],{"class":519},[472,3533,184],{"class":486},[472,3535,3536],{"class":549},"iterrows",[472,3538,3539],{"class":486},"():",[472,3541,3542],{"class":519},"              \n",[472,3544,3545],{"class":474,"line":575},[472,3546,3547],{"class":513},"    # Make sure we always have a move to compare to (+1 because range is non-inclusive)\n",[472,3549,3550,3553,3556,3558,3560,3562,3564,3566,3569,3571,3573,3575,3577],{"class":474,"line":621},[472,3551,3552],{"class":478},"    for",[472,3554,3555],{"class":519}," move_num ",[472,3557,813],{"class":478},[472,3559,2980],{"class":525},[472,3561,487],{"class":486},[472,3563,824],{"class":504},[472,3565,494],{"class":486},[472,3567,3568],{"class":519}," max_ply ",[472,3570,794],{"class":500},[472,3572,1678],{"class":504},[472,3574,679],{"class":500},[472,3576,682],{"class":504},[472,3578,508],{"class":486},[472,3580,3581],{"class":474,"line":627},[472,3582,3583],{"class":513},"        # Determine the color to see if we need to multiply the evaluation by -1\n",[472,3585,3586,3589,3591,3594,3596,3598,3601,3603,3606,3608,3610],{"class":474,"line":633},[472,3587,3588],{"class":519},"        color ",[472,3590,501],{"class":500},[472,3592,3593],{"class":536}," 'white'",[472,3595,3235],{"class":478},[472,3597,3555],{"class":519},[472,3599,3600],{"class":500},"%",[472,3602,1678],{"class":504},[472,3604,3605],{"class":500}," ==",[472,3607,682],{"class":504},[472,3609,3252],{"class":478},[472,3611,3612],{"class":536}," 'black'\n",[472,3614,3615],{"class":474,"line":660},[472,3616,3617],{"class":513},"        # Column names for current and next move\n",[472,3619,3620,3623,3625,3627,3629,3631,3634,3636],{"class":474,"line":691},[472,3621,3622],{"class":519},"        curr_time_col ",[472,3624,501],{"class":500},[472,3626,854],{"class":540},[472,3628,3143],{"class":536},[472,3630,772],{"class":771},[472,3632,3633],{"class":519},"move_num",[472,3635,778],{"class":771},[472,3637,801],{"class":536},[472,3639,3640,3643,3645,3647,3649,3651,3654,3656,3658,3660],{"class":474,"line":696},[472,3641,3642],{"class":519},"        next_time_col ",[472,3644,501],{"class":500},[472,3646,854],{"class":540},[472,3648,3143],{"class":536},[472,3650,772],{"class":771},[472,3652,3653],{"class":519},"move_num ",[472,3655,729],{"class":500},[472,3657,1678],{"class":504},[472,3659,778],{"class":771},[472,3661,801],{"class":536},[472,3663,3664,3667,3669,3671,3673,3675,3677,3679],{"class":474,"line":702},[472,3665,3666],{"class":519},"        curr_eval_col ",[472,3668,501],{"class":500},[472,3670,854],{"class":540},[472,3672,3077],{"class":536},[472,3674,772],{"class":771},[472,3676,3633],{"class":519},[472,3678,778],{"class":771},[472,3680,801],{"class":536},[472,3682,3683,3686,3688,3690,3692,3694,3696,3698,3700,3702],{"class":474,"line":741},[472,3684,3685],{"class":519},"        next_eval_col ",[472,3687,501],{"class":500},[472,3689,854],{"class":540},[472,3691,3077],{"class":536},[472,3693,772],{"class":771},[472,3695,3653],{"class":519},[472,3697,729],{"class":500},[472,3699,1678],{"class":504},[472,3701,778],{"class":771},[472,3703,801],{"class":536},[33,3705,3706],{},"We do all the necessary checks to see if all values are valid, before applying the eval_conversion function we wrote earlier.",[463,3708,3710],{"className":465,"code":3709,"language":467,"meta":407,"style":407},"# Check if all columns exist\nif not all(col in df.columns for col in \n[curr_time_col, next_time_col, curr_eval_col, next_eval_col]):\n    continue\n# Convert evaluations to numeric (or None)\ncurr_eval = eval_conversion(row[curr_eval_col])\nnext_eval = eval_conversion(row[next_eval_col])\n# Skip current move if either evaluation is None\nif curr_eval is None or next_eval is None:\n    continue\n# Check for valid clock times\nif pd.isnull(row[curr_time_col]) or pd.isnull(row[next_time_col]):\n    continue\n",[469,3711,3712,3717,3748,3773,3778,3783,3804,3824,3829,3854,3858,3863,3903],{"__ignoreMap":407},[472,3713,3714],{"class":474,"line":475},[472,3715,3716],{"class":513},"# Check if all columns exist\n",[472,3718,3719,3721,3724,3727,3729,3731,3733,3735,3737,3739,3741,3743,3745],{"class":474,"line":411},[472,3720,1297],{"class":478},[472,3722,3723],{"class":478}," not",[472,3725,3726],{"class":525}," all",[472,3728,487],{"class":486},[472,3730,1279],{"class":519},[472,3732,813],{"class":478},[472,3734,556],{"class":519},[472,3736,184],{"class":486},[472,3738,1294],{"class":519},[472,3740,1282],{"class":478},[472,3742,1285],{"class":519},[472,3744,813],{"class":478},[472,3746,3747],{"class":519}," \n",[472,3749,3750,3752,3755,3757,3760,3762,3765,3767,3770],{"class":474,"line":408},[472,3751,533],{"class":486},[472,3753,3754],{"class":519},"curr_time_col",[472,3756,494],{"class":486},[472,3758,3759],{"class":519}," next_time_col",[472,3761,494],{"class":486},[472,3763,3764],{"class":519}," curr_eval_col",[472,3766,494],{"class":486},[472,3768,3769],{"class":519}," next_eval_col",[472,3771,3772],{"class":486},"]):\n",[472,3774,3775],{"class":474,"line":575},[472,3776,3777],{"class":478},"    continue\n",[472,3779,3780],{"class":474,"line":621},[472,3781,3782],{"class":513},"# Convert evaluations to numeric (or None)\n",[472,3784,3785,3788,3790,3792,3794,3797,3799,3802],{"class":474,"line":627},[472,3786,3787],{"class":519},"curr_eval ",[472,3789,501],{"class":500},[472,3791,3371],{"class":549},[472,3793,487],{"class":486},[472,3795,3796],{"class":490},"row",[472,3798,533],{"class":486},[472,3800,3801],{"class":490},"curr_eval_col",[472,3803,2526],{"class":486},[472,3805,3806,3809,3811,3813,3815,3817,3819,3822],{"class":474,"line":633},[472,3807,3808],{"class":519},"next_eval ",[472,3810,501],{"class":500},[472,3812,3371],{"class":549},[472,3814,487],{"class":486},[472,3816,3796],{"class":490},[472,3818,533],{"class":486},[472,3820,3821],{"class":490},"next_eval_col",[472,3823,2526],{"class":486},[472,3825,3826],{"class":474,"line":660},[472,3827,3828],{"class":513},"# Skip current move if either evaluation is None\n",[472,3830,3831,3833,3836,3839,3842,3845,3848,3850,3852],{"class":474,"line":691},[472,3832,1297],{"class":478},[472,3834,3835],{"class":519}," curr_eval ",[472,3837,3838],{"class":478},"is",[472,3840,3841],{"class":504}," None",[472,3843,3844],{"class":478}," or",[472,3846,3847],{"class":519}," next_eval ",[472,3849,3838],{"class":478},[472,3851,3841],{"class":504},[472,3853,2537],{"class":486},[472,3855,3856],{"class":474,"line":696},[472,3857,3777],{"class":478},[472,3859,3860],{"class":474,"line":702},[472,3861,3862],{"class":513},"# Check for valid clock times\n",[472,3864,3865,3867,3869,3871,3873,3875,3877,3879,3881,3884,3886,3888,3890,3892,3894,3896,3898,3901],{"class":474,"line":741},[472,3866,1297],{"class":478},[472,3868,911],{"class":519},[472,3870,184],{"class":486},[472,3872,3389],{"class":549},[472,3874,487],{"class":486},[472,3876,3796],{"class":490},[472,3878,533],{"class":486},[472,3880,3754],{"class":490},[472,3882,3883],{"class":486},"])",[472,3885,3844],{"class":478},[472,3887,911],{"class":519},[472,3889,184],{"class":486},[472,3891,3389],{"class":549},[472,3893,487],{"class":486},[472,3895,3796],{"class":490},[472,3897,533],{"class":486},[472,3899,3900],{"class":490},"next_time_col",[472,3902,3772],{"class":486},[472,3904,3905],{"class":474,"line":746},[472,3906,3777],{"class":478},[33,3908,3909],{},"Finally, we can calculate the time spent on each move, and the change in computer evaluation. The phase of the game the move was made in is converted, and then a dictionary with all the data for that move is made and appended to the move list.",[463,3911,3913],{"className":465,"code":3912,"language":467,"meta":407,"style":407},"# Calculate time spent and eval change\ntime_spent = row[curr_time_col] - row[next_time_col] + row['Increment']\neval_change = next_eval - curr_eval\n# Determine rough phase of the game the move was made in\ndef get_game_phase(move_num):\n    if move_num \u003C= 10:\n        return 'opening'\n    elif move_num \u003C= 20:\n        return 'early_middle'\n    elif move_num \u003C= 40:\n        return 'late_middle'\n    else:\n        return 'endgame'\ngame_phase = get_game_phase(move_num)\n# Store move data\nmove_data = {\n    'game_id': idx,\n    'move_number': (move_num + 1) // 2,\n    'color': color,\n    'time_spent': time_spent,\n    'eval_change': round(eval_change if color == 'white' else -eval_change, 2),\n    'game_phase': game_phase,\n    'increment': row['Increment'],\n    'game_mode': row['GameMode']\n}\n# After processing each game, append the move data to the main list\nall_moves.append(move_data)\n",[469,3914,3915,3920,3960,3974,3979,3992,4005,4012,4026,4033,4046,4053,4060,4067,4082,4087,4097,4108,4131,4143,4155,4193,4205,4225,4244,4249,4254],{"__ignoreMap":407},[472,3916,3917],{"class":474,"line":475},[472,3918,3919],{"class":513},"# Calculate time spent and eval change\n",[472,3921,3922,3925,3927,3930,3932,3934,3936,3938,3940,3942,3944,3946,3948,3950,3952,3954,3956,3958],{"class":474,"line":411},[472,3923,3924],{"class":519},"time_spent ",[472,3926,501],{"class":500},[472,3928,3929],{"class":490}," row",[472,3931,533],{"class":486},[472,3933,3754],{"class":490},[472,3935,848],{"class":486},[472,3937,2904],{"class":500},[472,3939,3929],{"class":490},[472,3941,533],{"class":486},[472,3943,3900],{"class":490},[472,3945,848],{"class":486},[472,3947,679],{"class":500},[472,3949,3929],{"class":490},[472,3951,533],{"class":486},[472,3953,537],{"class":536},[472,3955,1156],{"class":540},[472,3957,537],{"class":536},[472,3959,827],{"class":486},[472,3961,3962,3965,3967,3969,3971],{"class":474,"line":408},[472,3963,3964],{"class":519},"eval_change ",[472,3966,501],{"class":500},[472,3968,3847],{"class":519},[472,3970,794],{"class":500},[472,3972,3973],{"class":519}," curr_eval\n",[472,3975,3976],{"class":474,"line":575},[472,3977,3978],{"class":513},"# Determine rough phase of the game the move was made in\n",[472,3980,3981,3983,3986,3988,3990],{"class":474,"line":621},[472,3982,479],{"class":478},[472,3984,3985],{"class":482}," get_game_phase",[472,3987,487],{"class":486},[472,3989,3633],{"class":490},[472,3991,508],{"class":486},[472,3993,3994,3996,3998,4001,4003],{"class":474,"line":627},[472,3995,2532],{"class":478},[472,3997,3555],{"class":519},[472,3999,4000],{"class":500},"\u003C=",[472,4002,2850],{"class":504},[472,4004,2537],{"class":486},[472,4006,4007,4009],{"class":474,"line":633},[472,4008,3400],{"class":478},[472,4010,4011],{"class":536}," 'opening'\n",[472,4013,4014,4017,4019,4021,4024],{"class":474,"line":660},[472,4015,4016],{"class":478},"    elif",[472,4018,3555],{"class":519},[472,4020,4000],{"class":500},[472,4022,4023],{"class":504}," 20",[472,4025,2537],{"class":486},[472,4027,4028,4030],{"class":474,"line":691},[472,4029,3400],{"class":478},[472,4031,4032],{"class":536}," 'early_middle'\n",[472,4034,4035,4037,4039,4041,4044],{"class":474,"line":696},[472,4036,4016],{"class":478},[472,4038,3555],{"class":519},[472,4040,4000],{"class":500},[472,4042,4043],{"class":504}," 40",[472,4045,2537],{"class":486},[472,4047,4048,4050],{"class":474,"line":702},[472,4049,3400],{"class":478},[472,4051,4052],{"class":536}," 'late_middle'\n",[472,4054,4055,4058],{"class":474,"line":741},[472,4056,4057],{"class":478},"    else",[472,4059,2537],{"class":486},[472,4061,4062,4064],{"class":474,"line":746},[472,4063,3400],{"class":478},[472,4065,4066],{"class":536}," 'endgame'\n",[472,4068,4069,4072,4074,4076,4078,4080],{"class":474,"line":752},[472,4070,4071],{"class":519},"game_phase ",[472,4073,501],{"class":500},[472,4075,3985],{"class":549},[472,4077,487],{"class":486},[472,4079,3633],{"class":519},[472,4081,951],{"class":486},[472,4083,4084],{"class":474,"line":763},[472,4085,4086],{"class":513},"# Store move data\n",[472,4088,4089,4092,4094],{"class":474,"line":804},[472,4090,4091],{"class":519},"move_data ",[472,4093,501],{"class":500},[472,4095,4096],{"class":486}," {\n",[472,4098,4099,4102,4104,4106],{"class":474,"line":830},[472,4100,4101],{"class":536},"    'game_id'",[472,4103,320],{"class":486},[472,4105,3522],{"class":519},[472,4107,2560],{"class":486},[472,4109,4110,4113,4115,4117,4119,4121,4123,4125,4127,4129],{"class":474,"line":836},[472,4111,4112],{"class":536},"    'move_number'",[472,4114,320],{"class":486},[472,4116,640],{"class":486},[472,4118,3653],{"class":519},[472,4120,729],{"class":500},[472,4122,682],{"class":504},[472,4124,651],{"class":486},[472,4126,1437],{"class":500},[472,4128,1678],{"class":504},[472,4130,2560],{"class":486},[472,4132,4133,4136,4138,4141],{"class":474,"line":881},[472,4134,4135],{"class":536},"    'color'",[472,4137,320],{"class":486},[472,4139,4140],{"class":519}," color",[472,4142,2560],{"class":486},[472,4144,4145,4148,4150,4153],{"class":474,"line":886},[472,4146,4147],{"class":536},"    'time_spent'",[472,4149,320],{"class":486},[472,4151,4152],{"class":519}," time_spent",[472,4154,2560],{"class":486},[472,4156,4157,4160,4162,4165,4167,4169,4171,4174,4177,4179,4181,4183,4186,4188,4190],{"class":474,"line":892},[472,4158,4159],{"class":536},"    'eval_change'",[472,4161,320],{"class":486},[472,4163,4164],{"class":525}," round",[472,4166,487],{"class":486},[472,4168,3964],{"class":519},[472,4170,1297],{"class":478},[472,4172,4173],{"class":519}," color ",[472,4175,4176],{"class":500},"==",[472,4178,3593],{"class":536},[472,4180,3252],{"class":478},[472,4182,2904],{"class":500},[472,4184,4185],{"class":519},"eval_change",[472,4187,494],{"class":486},[472,4189,1678],{"class":504},[472,4191,4192],{"class":486},"),\n",[472,4194,4195,4198,4200,4203],{"class":474,"line":954},[472,4196,4197],{"class":536},"    'game_phase'",[472,4199,320],{"class":486},[472,4201,4202],{"class":519}," game_phase",[472,4204,2560],{"class":486},[472,4206,4207,4210,4212,4214,4216,4218,4220,4222],{"class":474,"line":1008},[472,4208,4209],{"class":536},"    'increment'",[472,4211,320],{"class":486},[472,4213,3929],{"class":490},[472,4215,533],{"class":486},[472,4217,537],{"class":536},[472,4219,1156],{"class":540},[472,4221,537],{"class":536},[472,4223,4224],{"class":486},"],\n",[472,4226,4227,4230,4232,4234,4236,4238,4240,4242],{"class":474,"line":1013},[472,4228,4229],{"class":536},"    'game_mode'",[472,4231,320],{"class":486},[472,4233,3929],{"class":490},[472,4235,533],{"class":486},[472,4237,537],{"class":536},[472,4239,1107],{"class":540},[472,4241,537],{"class":536},[472,4243,827],{"class":486},[472,4245,4246],{"class":474,"line":1019},[472,4247,4248],{"class":486},"}\n",[472,4250,4251],{"class":474,"line":1072},[472,4252,4253],{"class":513},"# After processing each game, append the move data to the main list\n",[472,4255,4256,4259,4261,4264,4266,4269],{"class":474,"line":1077},[472,4257,4258],{"class":519},"all_moves",[472,4260,184],{"class":486},[472,4262,4263],{"class":549},"append",[472,4265,487],{"class":486},[472,4267,4268],{"class":519},"move_data",[472,4270,951],{"class":486},[2618,4272,4273],{},"html pre.shiki code .se-gO, html code.shiki .se-gO{--shiki-light:#7C7F93;--shiki-light-font-style:italic;--shiki-default:#7C7F93;--shiki-default-font-style:italic;--shiki-dark:#939AB7;--shiki-dark-font-style:italic}html pre.shiki code .swLP3, html code.shiki .swLP3{--shiki-light:#4C4F69;--shiki-default:#4C4F69;--shiki-dark:#CAD3F5}html pre.shiki code .saHHS, html code.shiki .saHHS{--shiki-light:#179299;--shiki-default:#179299;--shiki-dark:#8BD5CA}html pre.shiki code .shMcR, html code.shiki .shMcR{--shiki-light:#7C7F93;--shiki-default:#7C7F93;--shiki-dark:#939AB7}html pre.shiki code .s3e4v, html code.shiki .s3e4v{--shiki-light:#40A02B;--shiki-light-font-style:italic;--shiki-default:#40A02B;--shiki-default-font-style:italic;--shiki-dark:#A6DA95;--shiki-dark-font-style:italic}html pre.shiki code .sPevk, html code.shiki .sPevk{--shiki-light:#40A02B;--shiki-default:#40A02B;--shiki-dark:#A6DA95}html pre.shiki code .siCgW, html code.shiki .siCgW{--shiki-light:#EA76CB;--shiki-default:#EA76CB;--shiki-dark:#F5BDE6}html pre.shiki code .sTQ8l, html code.shiki .sTQ8l{--shiki-light:#8839EF;--shiki-default:#8839EF;--shiki-dark:#C6A0F6}html pre.shiki code .sV1I6, html code.shiki .sV1I6{--shiki-light:#FE640B;--shiki-light-font-style:italic;--shiki-default:#FE640B;--shiki-default-font-style:italic;--shiki-dark:#F5A97F;--shiki-dark-font-style:italic}html pre.shiki code .sI2Su, html code.shiki .sI2Su{--shiki-light:#FE640B;--shiki-default:#FE640B;--shiki-dark:#F5A97F}html pre.shiki code .s1dUP, html code.shiki .s1dUP{--shiki-light:#E64553;--shiki-light-font-style:italic;--shiki-default:#E64553;--shiki-default-font-style:italic;--shiki-dark:#EE99A0;--shiki-dark-font-style:italic}html pre.shiki code .sBYUN, html code.shiki .sBYUN{--shiki-light:#1E66F5;--shiki-default:#1E66F5;--shiki-dark:#8AADF4}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZJYN, html code.shiki .sZJYN{--shiki-light:#1E66F5;--shiki-light-font-style:italic;--shiki-default:#1E66F5;--shiki-default-font-style:italic;--shiki-dark:#8AADF4;--shiki-dark-font-style:italic}html pre.shiki code .sdQ9k, html code.shiki .sdQ9k{--shiki-light:#8839EF;--shiki-light-font-style:italic;--shiki-default:#8839EF;--shiki-default-font-style:italic;--shiki-dark:#C6A0F6;--shiki-dark-font-style:italic}",{"title":407,"searchDepth":408,"depth":408,"links":4275},[],{},"/blog/chess-games/snippets/time-eval",{"description":407},"blog/chess-games/snippets/time-eval","w1BFaACkTfzM-WEI8JmZ4wdfqv-X-JrUvImAyc3kKUo",1792076567566]