Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
wcj365 committed Dec 4, 2020
1 parent fbfcc9f commit 9ecc56f
Showing 1 changed file with 341 additions and 0 deletions.
341 changes: 341 additions & 0 deletions examples/data_wrangling.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,341 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "data_wrangling.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyOJBFOQYb0eJBdd+DCxzbPq",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/wcj365/python-stats-dataviz/blob/master/examples/data_wrangling.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "5Yj3KfmDLlU7"
},
"source": [
"line = \"FeasibilityTol 1e-09|OptimalityTol 1e-09|BarQCPConvTol 0|GomoryPasses 0|AggFill 1000|NumericFocus 3|PrePasses 8|Presolve 1|Threads 8|TuneTimeLimit 60|TuneResults 1|TuneCriterion 0|Original Runtime:0.06244611740112305New Runtime:0.09337711334228516\""
],
"execution_count": 1,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Sc31s9ZlMCKA",
"outputId": "097ff3fb-d503-48b4-c7ad-a198acb40a10"
},
"source": [
"type(line)"
],
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"str"
]
},
"metadata": {
"tags": []
},
"execution_count": 2
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "EjCwBSHoMHna",
"outputId": "e25400d6-254a-4bc8-e146-371cb78fc31e"
},
"source": [
"items = line.split(\"|\")\n",
"print(items)"
],
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"text": [
"['FeasibilityTol 1e-09', 'OptimalityTol 1e-09', 'BarQCPConvTol 0', 'GomoryPasses 0', 'AggFill 1000', 'NumericFocus 3', 'PrePasses 8', 'Presolve 1', 'Threads 8', 'TuneTimeLimit 60', 'TuneResults 1', 'TuneCriterion 0', 'Original Runtime:0.06244611740112305New Runtime:0.09337711334228516']\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Mv4OJghHNDGX",
"outputId": "ef26b824-2d67-4e62-d449-9dfa4d9ec7d2"
},
"source": [
"len(items)"
],
"execution_count": 6,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"13"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "MPZXwN7lNLvV",
"outputId": "83a1631e-2989-441d-d722-a5856f931cf4"
},
"source": [
"last_item = items[-1]\n",
"last_item"
],
"execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'Original Runtime:0.06244611740112305New Runtime:0.09337711334228516'"
]
},
"metadata": {
"tags": []
},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "AdKatWYlNhz7",
"outputId": "ef5e881a-e1eb-42f7-99e9-f739d4e954cc"
},
"source": [
"last_item.find(\"New\")"
],
"execution_count": 13,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"36"
]
},
"metadata": {
"tags": []
},
"execution_count": 13
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "_1SjwyFdN6cy",
"outputId": "0c73ed8e-d854-405c-8e5b-3def981d7759"
},
"source": [
"part_1 = last_item[0:36]\n",
"part_1"
],
"execution_count": 15,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'Original Runtime:0.06244611740112305'"
]
},
"metadata": {
"tags": []
},
"execution_count": 15
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "2mmnhtxKOOtE",
"outputId": "2837d71f-630e-4328-ee88-8dbf8cad07f5"
},
"source": [
"part_2 = last_item[36:]\n",
"part_2"
],
"execution_count": 20,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'New Runtime:0.09337711334228516'"
]
},
"metadata": {
"tags": []
},
"execution_count": 20
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "SXHXXE3COr4G",
"outputId": "982e2155-3de3-42a3-c566-cc5864b26f6e"
},
"source": [
"orig_time = part_1.split(\":\")[1]\n",
"orig_time"
],
"execution_count": 23,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'0.06244611740112305'"
]
},
"metadata": {
"tags": []
},
"execution_count": 23
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "cI-YZXroPNva",
"outputId": "e2211f24-a29a-477a-81e7-853e3ac67a39"
},
"source": [
"new_time = part_2.split(\":\")[1]\n",
"new_time"
],
"execution_count": 24,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'0.09337711334228516'"
]
},
"metadata": {
"tags": []
},
"execution_count": 24
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Fr5NpbnRPTdZ",
"outputId": "2b2a5c87-faa5-407c-c98b-16f200632b88"
},
"source": [
"diff = float(new_time) - float(orig_time)\n",
"diff"
],
"execution_count": 26,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0.03093099594116211"
]
},
"metadata": {
"tags": []
},
"execution_count": 26
}
]
}
]
}

0 comments on commit 9ecc56f

Please sign in to comment.