{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-03-28T20:36:55.924038Z","iopub.execute_input":"2023-03-28T20:36:55.924489Z","iopub.status.idle":"2023-03-28T20:36:55.934041Z","shell.execute_reply.started":"2023-03-28T20:36:55.924447Z","shell.execute_reply":"2023-03-28T20:36:55.933099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install pyspark\nimport pyspark","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:36:55.935968Z","iopub.execute_input":"2023-03-28T20:36:55.937344Z","iopub.status.idle":"2023-03-28T20:37:07.346269Z","shell.execute_reply.started":"2023-03-28T20:36:55.937298Z","shell.execute_reply":"2023-03-28T20:37:07.345218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from pyspark.sql import SparkSession\nspark = SparkSession.builder.master(\"local[1]\").appName(\"SparkByExamples.com\").getOrCreate()\ntrain = spark.read.csv(\"/kaggle/input/predict-student-performance-from-game-play/train.csv\",header=True)\ntrain.show(5)","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:37:36.655283Z","iopub.execute_input":"2023-03-28T20:37:36.655711Z","iopub.status.idle":"2023-03-28T20:37:37.122162Z","shell.execute_reply.started":"2023-03-28T20:37:36.655674Z","shell.execute_reply":"2023-03-28T20:37:37.120688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.printSchema()","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:38:37.187144Z","iopub.execute_input":"2023-03-28T20:38:37.187562Z","iopub.status.idle":"2023-03-28T20:38:37.195861Z","shell.execute_reply.started":"2023-03-28T20:38:37.187525Z","shell.execute_reply":"2023-03-28T20:38:37.194980Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.show(1)","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:39:41.753649Z","iopub.execute_input":"2023-03-28T20:39:41.754057Z","iopub.status.idle":"2023-03-28T20:39:41.910942Z","shell.execute_reply.started":"2023-03-28T20:39:41.754022Z","shell.execute_reply":"2023-03-28T20:39:41.909911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = spark.read.csv(\"/kaggle/input/predict-student-performance-from-game-play/test.csv\",header=True)","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:40:41.252577Z","iopub.execute_input":"2023-03-28T20:40:41.253029Z","iopub.status.idle":"2023-03-28T20:40:41.519988Z","shell.execute_reply.started":"2023-03-28T20:40:41.252993Z","shell.execute_reply":"2023-03-28T20:40:41.519016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:55:41.028884Z","iopub.execute_input":"2023-03-28T20:55:41.029286Z","iopub.status.idle":"2023-03-28T20:55:41.190313Z","shell.execute_reply.started":"2023-03-28T20:55:41.029250Z","shell.execute_reply":"2023-03-28T20:55:41.189284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels = spark.read.csv('/kaggle/input/predict-student-performance-from-game-play/train_labels.csv',header=True)","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:42:52.417974Z","iopub.execute_input":"2023-03-28T20:42:52.418390Z","iopub.status.idle":"2023-03-28T20:42:52.638306Z","shell.execute_reply.started":"2023-03-28T20:42:52.418355Z","shell.execute_reply":"2023-03-28T20:42:52.637297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels.show(5)","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:57:47.385192Z","iopub.execute_input":"2023-03-28T20:57:47.385661Z","iopub.status.idle":"2023-03-28T20:57:47.468574Z","shell.execute_reply.started":"2023-03-28T20:57:47.385623Z","shell.execute_reply":"2023-03-28T20:57:47.467566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"merged_df = train.unionByName(labels, allowMissingColumns=True)","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:43:52.717696Z","iopub.execute_input":"2023-03-28T20:43:52.718078Z","iopub.status.idle":"2023-03-28T20:43:52.760986Z","shell.execute_reply.started":"2023-03-28T20:43:52.718046Z","shell.execute_reply":"2023-03-28T20:43:52.760009Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"merged_df.show(5)","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:44:08.359428Z","iopub.execute_input":"2023-03-28T20:44:08.359851Z","iopub.status.idle":"2023-03-28T20:44:08.643311Z","shell.execute_reply.started":"2023-03-28T20:44:08.359816Z","shell.execute_reply":"2023-03-28T20:44:08.642281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv('/kaggle/input/predict-student-performance-from-game-play/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-03-28T20:55:25.630104Z","iopub.execute_input":"2023-03-28T20:55:25.630509Z","iopub.status.idle":"2023-03-28T20:55:25.648851Z","shell.execute_reply.started":"2023-03-28T20:55:25.630474Z","shell.execute_reply":"2023-03-28T20:55:25.647553Z"},"trusted":true},"execution_count":null,"outputs":[]}]}