{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Workbook for Eye Tracking Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import Libraries" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Basics\n", "import numpy as np\n", "import os\n", "import math\n", "\n", "# Data processing\n", "import pandas as pd\n", "import awkward as ak\n", "\n", "# ML\n", "import sklearn\n", "\n", "# Misc\n", "from pathlib import Path\n", "import pyarrow as pa\n", "import urllib.request" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import users and their score" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Imports the user score information\n", "user_data = pd.read_csv(r\"wetransfer_wtg-ar-daten_2023-05-31_1333/scores_WtG_PrePost.csv\", delimiter=\",\", usecols=[\"User\", \"Pre score\", \"Post score\", \"Difference\", \"Group cat\"])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Defines my directory with the user data\n", "user_dir = 'wetransfer_wtg-ar-daten_2023-05-31_1333/WtG_AR_data_cleaned/with ET'" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Filters and drops non-relevant users\n", "to_drop = []\n", "for i, cat in enumerate(user_data[\"Group cat\"]):\n", " if math.isnan(cat):\n", " to_drop.append(i)\n", "user_data = user_data.drop(to_drop)\n", "user_data = user_data.reset_index()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Filters and drops users with no directory\n", "not_existing_names = []\n", "for i, user in enumerate(user_data[\"User\"]):\n", " if not os.path.isdir(user_dir + '/' + user):\n", " not_existing_names.append(i)\n", "user_data = user_data.drop(not_existing_names)\n", "user_data = user_data.reset_index()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "<pre>[{level_0: 0, index: 0, User: '12C', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 1, index: 1, User: '13C', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 2, index: 2, User: '14A', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 3, index: 3, User: '15A', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 4, index: 4, User: '16A', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 5, index: 5, User: '17A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 6, index: 6, User: '19A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 7, index: 7, User: '1A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 8, index: 8, User: '20A', 'Pre score': 0, 'Post score': 0, ...},\n", " {level_0: 9, index: 9, User: '21A', 'Pre score': 1, 'Post score': 1, ...},\n", " ...,\n", " {level_0: 31, index: 33, User: '62A', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 32, index: 34, User: '64A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 33, index: 35, User: '66A', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 34, index: 36, User: '67A', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 35, index: 37, User: '69B', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 36, index: 38, User: '70A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 37, index: 39, User: '72B', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 38, index: 40, User: '74A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 39, index: 41, User: '75A', 'Pre score': 2, 'Post score': 2, ...}]\n", "-----------------------------------------------------------------------------\n", "type: 36 * {\n", " level_0: int64,\n", " index: int64,\n", " User: string,\n", " "Pre score": float64,\n", " "Post score": float64,\n", " Difference: int64,\n", " "Group cat": float64\n", "}</pre>" ], "text/plain": [ "<Array [{level_0: 0, index: 0, ...}, ...] type='36 * {level_0: int64, index...'>" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Convert to awkward array\n", "array_user = ak.zip(dict(user_data))\n", "array_user" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import Eye Tracking data" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Creates dictionary with all the files for one user\n", "file_names = {}\n", "for user in user_data[\"User\"]:\n", " #print(user)\n", " available_files = os.listdir(user_dir + '/' + user)\n", " #print(available_files)\n", " file_names[user] = available_files\n", "#file_names" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "36\n", "36\n" ] } ], "source": [ "# Read each CSV file for one user, stored for each attempt\n", "df_attempt1 = []\n", "df_attempt2 = []\n", "for user in user_data['User']:\n", " files = file_names[user]\n", " if len(files) == 2:\n", " df_attempt1.append(pd.read_csv(user_dir + '/' + user + '/' + files[0], delimiter=\"\t\", usecols=[\"eyeDataTimestamp\", \"gazePointAOI_target_x\", \"gazePointAOI_target_y\"]))\n", " df_attempt2.append(pd.read_csv(user_dir + '/' + user + '/' + files[1], delimiter=\"\t\", usecols=[\"eyeDataTimestamp\", \"gazePointAOI_target_x\", \"gazePointAOI_target_y\"]))\n", " elif len(files) == 1:\n", " df_attempt1.append(pd.read_csv(user_dir + '/' + user + '/' + files[0], delimiter=\"\t\", usecols=[\"eyeDataTimestamp\", \"gazePointAOI_target_x\", \"gazePointAOI_target_y\"]))\n", " df_attempt2.append(pd.read_csv(user_dir + '/' + user + '/' + files[0], delimiter=\"\t\", usecols=[\"eyeDataTimestamp\", \"gazePointAOI_target_x\", \"gazePointAOI_target_y\"]))\n", "print(len(df_attempt1))\n", "print(len(df_attempt2))\n", "#df_attempt1" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Read each CSV file in user_dir\n", "#files = []\n", "#dfs = []\n", "#for file in Path(user_dir).glob(\"**/*.csv\"):\n", "# files.append(file)\n", "# dfs.append(pd.read_csv(file, delimiter=\"\t\", usecols=[\"eyeDataTimestamp\", \"gazePointAOI_target_x\", \"gazePointAOI_target_y\"]))\n", "#dfs" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "[<Array [{eyeDataTimestamp: ..., ...}, ...] type='2429 * {eyeDataTimestamp: ...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='445 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='216 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='153 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='364 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='810 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='200 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='316 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='463 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='157 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='745 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='246 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='125 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='423 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='1418 * {eyeDataTimestamp: ...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='1553 * {eyeDataTimestamp: ...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='130 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='1074 * {eyeDataTimestamp: ...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='198 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='168 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='327 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='580 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='219 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='236 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='186 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='121 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='315 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='222 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='133 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='1251 * {eyeDataTimestamp: ...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='469 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='255 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='74 * {eyeDataTimestamp: in...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='785 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='316 * {eyeDataTimestamp: i...'>,\n", " <Array [{eyeDataTimestamp: ..., ...}, ...] type='129 * {eyeDataTimestamp: i...'>]" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Convert df_attempts to ak.Array\n", "array_attempt1 = []\n", "array_attempt2 = []\n", "for df in df_attempt1:\n", " array_attempt1.append(ak.Array(dict(df)))\n", "for df in df_attempt2:\n", " array_attempt2.append(ak.Array(dict(df)))\n", "array_attempt1" ] }, { "cell_type": "markdown", "metadata": { "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "### Test with single .csv" ] }, { "cell_type": "code", "execution_count": 108, "metadata": { "tags": [] }, "outputs": [], "source": [ "df1 = pd.read_csv(user_dir + r\"/1A/2020_11_03-01_58_35-graph01-ET_planning-1A-Graph_Hololens.csv\", delimiter=\"\t\", usecols=[\"eyeDataTimestamp\", \"gazePointAOI_target_x\", \"gazePointAOI_target_y\"])\n", "df2 = pd.read_csv(user_dir + r\"/1A/2020_11_03-01_59_11-graph01-ET_planning-1A-Graph_Hololens.csv\", delimiter=\"\t\", usecols=[\"eyeDataTimestamp\", \"gazePointAOI_target_x\", \"gazePointAOI_target_y\"])" ] }, { "cell_type": "code", "execution_count": 109, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>eyeDataTimestamp</th>\n", " <th>gazePointAOI_target_x</th>\n", " <th>gazePointAOI_target_y</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>1604397462436</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>1604397462469</td>\n", " <td>0.13731</td>\n", " <td>-0.23269</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>1604397462502</td>\n", " <td>0.18260</td>\n", " <td>-0.20021</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>1604397462536</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>1604397462569</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>1468</th>\n", " <td>1604397511370</td>\n", " <td>0.04413</td>\n", " <td>-0.20095</td>\n", " </tr>\n", " <tr>\n", " <th>1469</th>\n", " <td>1604397511403</td>\n", " <td>0.04517</td>\n", " <td>-0.20161</td>\n", " </tr>\n", " <tr>\n", " <th>1470</th>\n", " <td>1604397511436</td>\n", " <td>0.04554</td>\n", " <td>-0.20434</td>\n", " </tr>\n", " <tr>\n", " <th>1471</th>\n", " <td>1604397511470</td>\n", " <td>0.04488</td>\n", " <td>-0.20405</td>\n", " </tr>\n", " <tr>\n", " <th>1472</th>\n", " <td>1604397511503</td>\n", " <td>0.04554</td>\n", " <td>-0.20371</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>1473 rows × 3 columns</p>\n", "</div>" ], "text/plain": [ " eyeDataTimestamp gazePointAOI_target_x gazePointAOI_target_y\n", "0 1604397462436 NaN NaN\n", "1 1604397462469 0.13731 -0.23269\n", "2 1604397462502 0.18260 -0.20021\n", "3 1604397462536 NaN NaN\n", "4 1604397462569 NaN NaN\n", "... ... ... ...\n", "1468 1604397511370 0.04413 -0.20095\n", "1469 1604397511403 0.04517 -0.20161\n", "1470 1604397511436 0.04554 -0.20434\n", "1471 1604397511470 0.04488 -0.20405\n", "1472 1604397511503 0.04554 -0.20371\n", "\n", "[1473 rows x 3 columns]" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1" ] }, { "cell_type": "code", "execution_count": 250, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "<pre>[{eyeDataTimestamp: 1604397462436, gazePointAOI_target_x: nan, ...},\n", " {eyeDataTimestamp: 1604397462469, gazePointAOI_target_x: 0.137, ...},\n", " {eyeDataTimestamp: 1604397462502, gazePointAOI_target_x: 0.183, ...},\n", " {eyeDataTimestamp: 1604397462536, gazePointAOI_target_x: nan, ...},\n", " {eyeDataTimestamp: 1604397462569, gazePointAOI_target_x: nan, ...},\n", " {eyeDataTimestamp: 1604397462602, gazePointAOI_target_x: nan, ...},\n", " {eyeDataTimestamp: 1604397462636, gazePointAOI_target_x: nan, ...},\n", " {eyeDataTimestamp: 1604397462669, gazePointAOI_target_x: nan, ...},\n", " {eyeDataTimestamp: 1604397462702, gazePointAOI_target_x: nan, ...},\n", " {eyeDataTimestamp: 1604397462736, gazePointAOI_target_x: nan, ...},\n", " ...,\n", " {eyeDataTimestamp: 1604397511236, gazePointAOI_target_x: 0.0384, ...},\n", " {eyeDataTimestamp: 1604397511270, gazePointAOI_target_x: 0.0396, ...},\n", " {eyeDataTimestamp: 1604397511303, gazePointAOI_target_x: 0.0416, ...},\n", " {eyeDataTimestamp: 1604397511336, gazePointAOI_target_x: 0.043, ...},\n", " {eyeDataTimestamp: 1604397511370, gazePointAOI_target_x: 0.0441, ...},\n", " {eyeDataTimestamp: 1604397511403, gazePointAOI_target_x: 0.0452, ...},\n", " {eyeDataTimestamp: 1604397511436, gazePointAOI_target_x: 0.0455, ...},\n", " {eyeDataTimestamp: 1604397511470, gazePointAOI_target_x: 0.0449, ...},\n", " {eyeDataTimestamp: 1604397511503, gazePointAOI_target_x: 0.0455, ...}]\n", "-----------------------------------------------------------------------\n", "type: 1473 * {\n", " eyeDataTimestamp: int64,\n", " gazePointAOI_target_x: float64,\n", " gazePointAOI_target_y: float64\n", "}</pre>" ], "text/plain": [ "<Array [{eyeDataTimestamp: ..., ...}, ...] type='1473 * {eyeDataTimestamp: ...'>" ] }, "execution_count": 250, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Convert to awkward array\n", "array_column1 = ak.Array(dict(df1))\n", "array_column2 = ak.Array(dict(df2))\n", "array_column1" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "tags": [] }, "outputs": [], "source": [ "#array_column2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data processing" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### Add Eye Tracking Data to user data" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "tags": [] }, "outputs": [], "source": [ "def add_column_old_broken(ak_array1, ak_array2, col_name):\n", " entries = []\n", " for entry, dataframe in zip(ak_array1, ak_array2):\n", " entry_with_column = {**entry, col_name: dataframe}\n", " print(entry_with_column)\n", " entries.append(entry_with_column)\n", " print(entries)\n", " return ak.Array(entries)" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "tags": [] }, "outputs": [], "source": [ "def add_column_old(ak_array1, arrays, col_name):\n", " return ak.zip({**{k: ak_array1[k] for k in ak_array1.fields}, col_name: arrays})" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Adds a list of arrays in a new column to an array\n", "def add_column(ak_array, arrays, col_name):\n", " combined_entries = [\n", " {**{k: ak_array[k][i] for k in ak_array.fields}, col_name: array} for i, (entry, array) in enumerate(zip(ak_array, arrays))\n", " ]\n", " return ak.Array(combined_entries)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "tags": [] }, "outputs": [], "source": [ "#[{k: array_user[i][k] for k in array_user.fields} for i in range(36)]" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "<pre>[{level_0: 0, index: 0, User: '12C', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 1, index: 1, User: '13C', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 2, index: 2, User: '14A', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 3, index: 3, User: '15A', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 4, index: 4, User: '16A', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 5, index: 5, User: '17A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 6, index: 6, User: '19A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 7, index: 7, User: '1A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 8, index: 8, User: '20A', 'Pre score': 0, 'Post score': 0, ...},\n", " {level_0: 9, index: 9, User: '21A', 'Pre score': 1, 'Post score': 1, ...},\n", " ...,\n", " {level_0: 31, index: 33, User: '62A', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 32, index: 34, User: '64A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 33, index: 35, User: '66A', 'Pre score': 1, 'Post score': 2, ...},\n", " {level_0: 34, index: 36, User: '67A', 'Pre score': 1, 'Post score': 1, ...},\n", " {level_0: 35, index: 37, User: '69B', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 36, index: 38, User: '70A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 37, index: 39, User: '72B', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 38, index: 40, User: '74A', 'Pre score': 2, 'Post score': 2, ...},\n", " {level_0: 39, index: 41, User: '75A', 'Pre score': 2, 'Post score': 2, ...}]\n", "-----------------------------------------------------------------------------\n", "type: 36 * {\n", " level_0: int64,\n", " index: int64,\n", " User: string,\n", " "Pre score": float64,\n", " "Post score": float64,\n", " Difference: int64,\n", " "Group cat": float64,\n", " Attempt1: var * {\n", " eyeDataTimestamp: int64,\n", " gazePointAOI_target_x: float64,\n", " gazePointAOI_target_y: float64\n", " },\n", " Attempt2: var * {\n", " eyeDataTimestamp: int64,\n", " gazePointAOI_target_x: float64,\n", " gazePointAOI_target_y: float64\n", " }\n", "}</pre>" ], "text/plain": [ "<Array [{level_0: 0, index: 0, ...}, ...] type='36 * {level_0: int64, index...'>" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Creates array with first and second attempts added\n", "array_data = add_column(array_user, array_attempt1, 'Attempt1')\n", "array_data = add_column(array_data, array_attempt2, 'Attempt2')\n", "array_data" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "<pre>[{eyeDataTimestamp: 1604397536503, gazePointAOI_target_x: 0.0165, ...},\n", " {eyeDataTimestamp: 1604397536537, gazePointAOI_target_x: 0.0204, ...},\n", " {eyeDataTimestamp: 1604397536570, gazePointAOI_target_x: 0.0288, ...},\n", " {eyeDataTimestamp: 1604397536603, gazePointAOI_target_x: 0.032, ...},\n", " {eyeDataTimestamp: 1604397536637, gazePointAOI_target_x: 0.0373, ...},\n", " {eyeDataTimestamp: 1604397536670, gazePointAOI_target_x: 0.0376, ...},\n", " {eyeDataTimestamp: 1604397536703, gazePointAOI_target_x: 0.0382, ...},\n", " {eyeDataTimestamp: 1604397536737, gazePointAOI_target_x: 0.0351, ...},\n", " {eyeDataTimestamp: 1604397536770, gazePointAOI_target_x: 0.0374, ...},\n", " {eyeDataTimestamp: 1604397536803, gazePointAOI_target_x: 0.0418, ...},\n", " ...,\n", " {eyeDataTimestamp: 1604397546737, gazePointAOI_target_x: 0.0109, ...},\n", " {eyeDataTimestamp: 1604397546770, gazePointAOI_target_x: 0.0113, ...},\n", " {eyeDataTimestamp: 1604397546803, gazePointAOI_target_x: 0.0118, ...},\n", " {eyeDataTimestamp: 1604397546837, gazePointAOI_target_x: 0.0111, ...},\n", " {eyeDataTimestamp: 1604397546870, gazePointAOI_target_x: 0.0106, ...},\n", " {eyeDataTimestamp: 1604397546903, gazePointAOI_target_x: 0.012, ...},\n", " {eyeDataTimestamp: 1604397546937, gazePointAOI_target_x: 0.0133, ...},\n", " {eyeDataTimestamp: 1604397546970, gazePointAOI_target_x: 0.0172, ...},\n", " {eyeDataTimestamp: 1604397547003, gazePointAOI_target_x: 0.019, ...}]\n", "-----------------------------------------------------------------------\n", "type: 316 * {\n", " eyeDataTimestamp: int64,\n", " gazePointAOI_target_x: float64,\n", " gazePointAOI_target_y: float64\n", "}</pre>" ], "text/plain": [ "<Array [{eyeDataTimestamp: ..., ...}, ...] type='316 * {eyeDataTimestamp: i...'>" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "array_data['Attempt1'][7]" ] }, { "cell_type": "code", "execution_count": 105, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 105, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ak.all(array_data['Attempt1']['eyeDataTimestamp'][0] == array_data['Attempt1']['eyeDataTimestamp'][1])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 4 }