{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2024-06-08T09:52:47.287637Z", "start_time": "2024-06-08T09:52:46.348111Z" }, "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "id": "613252be66c5c97d", "metadata": { "ExecuteTime": { "end_time": "2024-06-08T09:53:28.061215Z", "start_time": "2024-06-08T09:53:28.039931Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CountryHappiness.RankHappiness.ScoreWhisker.highWhisker.lowEconomy..GDP.per.Capita.FamilyHealth..Life.Expectancy.FreedomGenerosityTrust..Government.Corruption.Dystopia.Residual
0Norway17.5377.5944457.4795561.6164631.5335240.7966670.6354230.3620120.3159642.277027
1Denmark27.5227.5817287.4622721.4823831.5511220.7925660.6260070.3552800.4007702.313707
2Iceland37.5047.6220307.3859701.4806331.6105740.8335520.6271630.4755400.1535272.322715
3Switzerland47.4947.5617727.4262271.5649801.5169120.8581310.6200710.2905490.3670072.276716
4Finland57.4697.5275427.4104581.4435721.5402470.8091580.6179510.2454830.3826122.430182
5Netherlands67.3777.4274267.3265741.5039451.4289390.8106960.5853840.4704900.2826622.294804
6Canada77.3167.3844037.2475971.4792041.4813490.8345580.6111010.4355400.2873722.187264
7New Zealand87.3147.3795107.2484901.4057061.5481950.8167600.6140620.5000050.3828172.046456
8Sweden97.2847.3440957.2239051.4943871.4781620.8308750.6129240.3853990.3843992.097538
9Australia107.2847.3566517.2113491.4844151.5100420.8438870.6016070.4776990.3011842.065211
\n", "
" ], "text/plain": [ " Country Happiness.Rank Happiness.Score Whisker.high Whisker.low \\\n", "0 Norway 1 7.537 7.594445 7.479556 \n", "1 Denmark 2 7.522 7.581728 7.462272 \n", "2 Iceland 3 7.504 7.622030 7.385970 \n", "3 Switzerland 4 7.494 7.561772 7.426227 \n", "4 Finland 5 7.469 7.527542 7.410458 \n", "5 Netherlands 6 7.377 7.427426 7.326574 \n", "6 Canada 7 7.316 7.384403 7.247597 \n", "7 New Zealand 8 7.314 7.379510 7.248490 \n", "8 Sweden 9 7.284 7.344095 7.223905 \n", "9 Australia 10 7.284 7.356651 7.211349 \n", "\n", " Economy..GDP.per.Capita. Family Health..Life.Expectancy. Freedom \\\n", "0 1.616463 1.533524 0.796667 0.635423 \n", "1 1.482383 1.551122 0.792566 0.626007 \n", "2 1.480633 1.610574 0.833552 0.627163 \n", "3 1.564980 1.516912 0.858131 0.620071 \n", "4 1.443572 1.540247 0.809158 0.617951 \n", "5 1.503945 1.428939 0.810696 0.585384 \n", "6 1.479204 1.481349 0.834558 0.611101 \n", "7 1.405706 1.548195 0.816760 0.614062 \n", "8 1.494387 1.478162 0.830875 0.612924 \n", "9 1.484415 1.510042 0.843887 0.601607 \n", "\n", " Generosity Trust..Government.Corruption. Dystopia.Residual \n", "0 0.362012 0.315964 2.277027 \n", "1 0.355280 0.400770 2.313707 \n", "2 0.475540 0.153527 2.322715 \n", "3 0.290549 0.367007 2.276716 \n", "4 0.245483 0.382612 2.430182 \n", "5 0.470490 0.282662 2.294804 \n", "6 0.435540 0.287372 2.187264 \n", "7 0.500005 0.382817 2.046456 \n", "8 0.385399 0.384399 2.097538 \n", "9 0.477699 0.301184 2.065211 " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(\"./data/world-happiness-report-2017.csv\")\n", "df.head(10)" ] }, { "cell_type": "code", "execution_count": 4, "id": "3065eaa0832b900b", "metadata": {}, "outputs": [], "source": [ "import openpyxl as pyx\n", "wb = pyx.load_workbook(\"./data.xlsx\")\n", "sheet = wb.active" ] }, { "cell_type": "code", "execution_count": 14, "id": "b80ffab6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(, , , , , , , )\n" ] } ], "source": [ "rows = sheet.rows\n", "for index in rows:\n", " print(index)" ] }, { "cell_type": "code", "execution_count": 18, "id": "693e6a84", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'class']\n" ] } ], "source": [ "with open(\"../data/iris.csv\") as file:\n", " first_line = file.readline()\n", "first_line = first_line.rstrip()\n", "title_list = first_line.split(\",\")\n", "print(title_list)" ] }, { "cell_type": "code", "execution_count": 19, "id": "6de1fc87", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['1111']\n" ] } ], "source": [ "str = \"1111\"\n", "print(str.split(\",\"))" ] } ], "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.11.4" } }, "nbformat": 4, "nbformat_minor": 5 }