pyqt_data_analysis/Test/data_show.ipynb

366 lines
12 KiB
Plaintext
Raw Normal View History

2024-06-08 19:26:36 +08:00
{
"cells": [
{
"cell_type": "code",
2024-06-09 02:54:44 +08:00
"execution_count": 1,
2024-06-08 19:26:36 +08:00
"id": "initial_id",
"metadata": {
"ExecuteTime": {
"end_time": "2024-06-08T09:52:47.287637Z",
"start_time": "2024-06-08T09:52:46.348111Z"
2024-06-09 02:54:44 +08:00
},
"collapsed": true
2024-06-08 19:26:36 +08:00
},
2024-06-09 02:54:44 +08:00
"outputs": [],
2024-06-08 19:26:36 +08:00
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd"
2024-06-09 02:54:44 +08:00
]
2024-06-08 19:26:36 +08:00
},
{
2024-06-09 02:54:44 +08:00
"cell_type": "code",
"execution_count": 2,
"id": "613252be66c5c97d",
2024-06-08 19:26:36 +08:00
"metadata": {
"ExecuteTime": {
"end_time": "2024-06-08T09:53:28.061215Z",
"start_time": "2024-06-08T09:53:28.039931Z"
}
},
"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>Country</th>\n",
" <th>Happiness.Rank</th>\n",
" <th>Happiness.Score</th>\n",
" <th>Whisker.high</th>\n",
" <th>Whisker.low</th>\n",
" <th>Economy..GDP.per.Capita.</th>\n",
" <th>Family</th>\n",
" <th>Health..Life.Expectancy.</th>\n",
" <th>Freedom</th>\n",
" <th>Generosity</th>\n",
" <th>Trust..Government.Corruption.</th>\n",
" <th>Dystopia.Residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Norway</td>\n",
" <td>1</td>\n",
" <td>7.537</td>\n",
" <td>7.594445</td>\n",
" <td>7.479556</td>\n",
" <td>1.616463</td>\n",
" <td>1.533524</td>\n",
" <td>0.796667</td>\n",
" <td>0.635423</td>\n",
" <td>0.362012</td>\n",
" <td>0.315964</td>\n",
" <td>2.277027</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Denmark</td>\n",
" <td>2</td>\n",
" <td>7.522</td>\n",
" <td>7.581728</td>\n",
" <td>7.462272</td>\n",
" <td>1.482383</td>\n",
" <td>1.551122</td>\n",
" <td>0.792566</td>\n",
" <td>0.626007</td>\n",
" <td>0.355280</td>\n",
" <td>0.400770</td>\n",
" <td>2.313707</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Iceland</td>\n",
" <td>3</td>\n",
" <td>7.504</td>\n",
" <td>7.622030</td>\n",
" <td>7.385970</td>\n",
" <td>1.480633</td>\n",
" <td>1.610574</td>\n",
" <td>0.833552</td>\n",
" <td>0.627163</td>\n",
" <td>0.475540</td>\n",
" <td>0.153527</td>\n",
" <td>2.322715</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Switzerland</td>\n",
" <td>4</td>\n",
" <td>7.494</td>\n",
" <td>7.561772</td>\n",
" <td>7.426227</td>\n",
" <td>1.564980</td>\n",
" <td>1.516912</td>\n",
" <td>0.858131</td>\n",
" <td>0.620071</td>\n",
" <td>0.290549</td>\n",
" <td>0.367007</td>\n",
" <td>2.276716</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Finland</td>\n",
" <td>5</td>\n",
" <td>7.469</td>\n",
" <td>7.527542</td>\n",
" <td>7.410458</td>\n",
" <td>1.443572</td>\n",
" <td>1.540247</td>\n",
" <td>0.809158</td>\n",
" <td>0.617951</td>\n",
" <td>0.245483</td>\n",
" <td>0.382612</td>\n",
" <td>2.430182</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Netherlands</td>\n",
" <td>6</td>\n",
" <td>7.377</td>\n",
" <td>7.427426</td>\n",
" <td>7.326574</td>\n",
" <td>1.503945</td>\n",
" <td>1.428939</td>\n",
" <td>0.810696</td>\n",
" <td>0.585384</td>\n",
" <td>0.470490</td>\n",
" <td>0.282662</td>\n",
" <td>2.294804</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Canada</td>\n",
" <td>7</td>\n",
" <td>7.316</td>\n",
" <td>7.384403</td>\n",
" <td>7.247597</td>\n",
" <td>1.479204</td>\n",
" <td>1.481349</td>\n",
" <td>0.834558</td>\n",
" <td>0.611101</td>\n",
" <td>0.435540</td>\n",
" <td>0.287372</td>\n",
" <td>2.187264</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>New Zealand</td>\n",
" <td>8</td>\n",
" <td>7.314</td>\n",
" <td>7.379510</td>\n",
" <td>7.248490</td>\n",
" <td>1.405706</td>\n",
" <td>1.548195</td>\n",
" <td>0.816760</td>\n",
" <td>0.614062</td>\n",
" <td>0.500005</td>\n",
" <td>0.382817</td>\n",
" <td>2.046456</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Sweden</td>\n",
" <td>9</td>\n",
" <td>7.284</td>\n",
" <td>7.344095</td>\n",
" <td>7.223905</td>\n",
" <td>1.494387</td>\n",
" <td>1.478162</td>\n",
" <td>0.830875</td>\n",
" <td>0.612924</td>\n",
" <td>0.385399</td>\n",
" <td>0.384399</td>\n",
" <td>2.097538</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Australia</td>\n",
" <td>10</td>\n",
" <td>7.284</td>\n",
" <td>7.356651</td>\n",
" <td>7.211349</td>\n",
" <td>1.484415</td>\n",
" <td>1.510042</td>\n",
" <td>0.843887</td>\n",
" <td>0.601607</td>\n",
" <td>0.477699</td>\n",
" <td>0.301184</td>\n",
" <td>2.065211</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
2024-06-09 02:54:44 +08:00
],
"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 "
2024-06-08 19:26:36 +08:00
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
2024-06-09 02:54:44 +08:00
"source": [
"df = pd.read_csv(\"./data/world-happiness-report-2017.csv\")\n",
"df.head(10)"
]
2024-06-08 19:26:36 +08:00
},
{
"cell_type": "code",
2024-06-09 02:54:44 +08:00
"execution_count": 4,
"id": "3065eaa0832b900b",
"metadata": {},
2024-06-08 19:26:36 +08:00
"outputs": [],
2024-06-09 02:54:44 +08:00
"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": [
"(<Cell 'Sheet1'.A1>, <Cell 'Sheet1'.B1>, <Cell 'Sheet1'.C1>, <Cell 'Sheet1'.D1>, <Cell 'Sheet1'.E1>, <Cell 'Sheet1'.F1>, <Cell 'Sheet1'.G1>, <Cell 'Sheet1'.H1>)\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(\",\"))"
]
2024-06-08 19:26:36 +08:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
2024-06-09 02:54:44 +08:00
"version": 3
2024-06-08 19:26:36 +08:00
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
2024-06-09 02:54:44 +08:00
"pygments_lexer": "ipython3",
"version": "3.11.4"
2024-06-08 19:26:36 +08:00
}
},
"nbformat": 4,
"nbformat_minor": 5
}