{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 7 - Final\n", "\n", "This final exercise combines different parts from the previous exercises." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Section 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1 Search Digitraffic's REST interface service (in JSON format) for active trains with the endpoint address `/live-trains` from Helsinki station with the following search parameters:\n", "* arrived_trains=10\n", "* departed_trains=10\n", "* include_nonstopping=False" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2 Read the data into the Pandas dataframe without editing, so that the column headings are as follows:\n", "\n", " `cancelled`,\n", " `commuterLineID`,\n", " `departureDate`,\n", " `operatorShortCode`,\n", " `operatorUICCode`,\n", " `runningCurrently`,\n", " `timeTableRows`,\n", " `timetableAcceptanceDate`,\n", " `timetableType`,\n", " `trainCategory`,\n", " `trainNumber`,\n", " `trainType`,\n", " `version`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3 Delete all other columns except `timeTableRows` and `trainNumber`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "4 After this, extract the values ​​of the `timeTableRows` column from each train separately (the column value for each train contains several JSON objects) and add `trainNumber`, which identifies the train data." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "5 Then drop the following columns from the data: `causes`, `differenceInMinutes` and `commercialStop`." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "6 Fill in the missing values ​​of the `actualTime` column in each row with the values of the `scheduledTime` column." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Section 2\n", "\n", "7 Extract the cell values ​​of the `table` element of the `data.html` file using the regex syntax and connect them to the dataframe created in step 1. **Note**: only regex should be used in the task (E.g. the use of Pandas' read_html() method is prohibited)!" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Section 3\n", "\n", "8 Make a SQLite database and insert the dataframe obtained as a result of step 2 to the database." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "#" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }