Minecraft Usage Data Processing Using Python

February 23, 2015

Report Abuse
This experiment demonstrates the use of a Python execution module to compute new columns dynamically from Minecraft usage CSV input data.
This experiment uses a Python execution module to compute new columns dynamically from Minecraft usage CSV input data. The CSV input data was generated over the course of a week of collecting Minecraft usage data - from my two boys :) The data consists of four fields: UserName - The Minecraft user name. StartTime - The start time of the Minecraft gaming session (when the JVM started) StopTime - The stop time of the Minecraft gaming session (when the JVM stopped). IPAddress - The IPAddress of the hosting computer. Prior to uploading the data to Microsoft Azure Machine Leaning, the UserName and IPAddress fields were encrypted (using the Python AES package library). To create the experiment, I first loaded the CSV input data as a saved dataset (called: 'minecraft-data-masked.csv'). Next, I added an "Execute Python Script" module and edited it with the following Python code: # Create new ElapsedTime column dataframe1['ElapsedTime'] = dataframe1['StopTime'] - dataframe1['StartTime'] # Create new TimeToNextStartTime column timeToNextStartTimes = [] for i in range(dataframe1.shape[0]): ----userName = dataframe1.iloc[i, 0] ----timeToNextStartTime = -1 ----for j in range (i+1, dataframe1.shape[0]): --------nextUserName = dataframe1.iloc[j, 0] --------if (userName == nextUserName): ------------stopTime = dataframe1.iloc[i, 2] ------------nextStartTime = dataframe1.iloc[j, 1] ------------timeToNextStartTime = nextStartTime - stopTime ------------break ----timeToNextStartTimes.append(timeToNextStartTime) dataframe1['TimeToNextStartTime'] = timeToNextStartTimes This is all that was needed to add two new columns dynamically - ElapsedTime and TimeToNextStartTime. Going forward, after more data have been collected, predictive models could be built to predict things such as the duration of play time or the next play time.