{ "cells": [ { "cell_type": "markdown", "id": "175f1599", "metadata": {}, "source": [ "# **FrodoBots Gaming Dataset**\n", "\n", "---" ] }, { "cell_type": "markdown", "id": "02a01f1c", "metadata": {}, "source": [ "## Data Analysis" ] }, { "cell_type": "markdown", "id": "0bdbda93", "metadata": {}, "source": [ "Find all control files in \"data_260523\" file, concat all control files into one table and save as \"combined_control.csv\"" ] }, { "cell_type": "code", "execution_count": 1, "id": "2c7cebdb", "metadata": {}, "outputs": [], "source": [ "import os\n", "import pandas as pd\n", "\n", "combined_control_df = pd.DataFrame()\n", "\n", "# Path to data_260523 directory\n", "data_directory = './data/data_260523'\n", "\n", "# Iterate through all directories and subdirectories\n", "for root, dirs, files in os.walk(data_directory):\n", " for file in files:\n", " # Check if the file is a control file\n", " if file.startswith('control'):\n", " # Full file path\n", " file_path = os.path.join(root, file)\n", " # Read the csv file into a dataframe\n", " try:\n", " df = pd.read_csv(file_path, on_bad_lines='skip')\n", " except Exception as e:\n", " print(f\"Error reading file {file_path}: {e}\")\n", " continue\n", " # Parse directory path to get the robot id and session id\n", " path_parts = root.split('/')\n", " robot_id = path_parts[-2]\n", " session_id = path_parts[-1]\n", " # Add robot id and session id to the dataframe\n", " df['Robot_ID'] = robot_id\n", " df['Session'] = session_id\n", " # Concatenate the dataframe with the combined dataframe\n", " combined_control_df = pd.concat([combined_control_df, df])\n", "\n", "# Save the combined dataframe as a csv file\n", "combined_control_df.to_csv('./data/combined_control.csv', index=False)" ] }, { "cell_type": "code", "execution_count": 3, "id": "64e6d8be", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | speed | \n", "angular | \n", "rpm_1 | \n", "rpm_2 | \n", "rpm_3 | \n", "rpm_4 | \n", "timestamp | \n", "Robot_ID | \n", "Session | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "0.45 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "
1 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "
2 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "
3 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "
4 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
8468211 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "
8468212 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "
8468213 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "
8468214 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "
8468215 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "frodobot31cdee | \n", "20230519033727 | \n", "
8468216 rows × 9 columns
\n", "\n", " | speed | \n", "angular | \n", "rpm_1 | \n", "rpm_2 | \n", "rpm_3 | \n", "rpm_4 | \n", "timestamp | \n", "Robot_ID | \n", "Session | \n", "actual_speed | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0.45 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "0.0 | \n", "
1 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "0.0 | \n", "
2 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "0.0 | \n", "
3 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "0.0 | \n", "
4 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.680601e+09 | \n", "frodobot2e6a30 | \n", "20230404102851 | \n", "0.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
8468211 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "0.0 | \n", "
8468212 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "0.0 | \n", "
8468213 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "0.0 | \n", "
8468214 | \n", "0.00 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.684464e+09 | \n", "frodobot31cdee | \n", "20230519033727 | \n", "0.0 | \n", "
8468215 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "frodobot31cdee | \n", "20230519033727 | \n", "NaN | \n", "
8468216 rows × 10 columns
\n", "