{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [], "source": [ "#从网页中的表格获取数据\n", "tb = pd.read_html('http://ranking.promisingedu.com/qs')" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "#如果页面有多个表格,根据需要选取\n", "df = tb[0]" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "df.to_csv('universityRank.csv')" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(500, 11)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.shape" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "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>Ranking</th>\n", " <th>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Academic Reputation</th>\n", " <th>Employer Reputation</th>\n", " <th>Faculty Student</th>\n", " <th>International Faculty</th>\n", " <th>International Students</th>\n", " <th>Citations per Faculty</th>\n", " <th>Overall Score</th>\n", " <th>Free</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>1</td>\n", " <td>麻省理工学院Massachusetts Institute of Technology</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100</td>\n", " <td>94.1</td>\n", " <td>99.8</td>\n", " <td>100.0</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>2</td>\n", " <td>斯坦福大学Stanford University</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>99.8</td>\n", " <td>67.7</td>\n", " <td>98.6</td>\n", " <td>98.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>3</td>\n", " <td>哈佛大学Harvard University</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>98.7</td>\n", " <td>86.3</td>\n", " <td>62.2</td>\n", " <td>99.6</td>\n", " <td>97.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>4</td>\n", " <td>牛津大学University of Oxford</td>\n", " <td>United Kingdom</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>99.7</td>\n", " <td>98.5</td>\n", " <td>84.7</td>\n", " <td>97.2</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>5</td>\n", " <td>加利福尼亚理工学院California Institute of Technology</td>\n", " <td>United States</td>\n", " <td>97.8</td>\n", " <td>81.2</td>\n", " <td>100.0</td>\n", " <td>99.4</td>\n", " <td>87.3</td>\n", " <td>100.0</td>\n", " <td>96.9</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Ranking University English Name Country/Region \\\n", "0 1 麻省理工学院Massachusetts Institute of Technology United States \n", "1 2 斯坦福大学Stanford University United States \n", "2 3 哈佛大学Harvard University United States \n", "3 4 牛津大学University of Oxford United Kingdom \n", "4 5 加利福尼亚理工学院California Institute of Technology United States \n", "\n", " Academic Reputation Employer Reputation Faculty Student \\\n", "0 100.0 100.0 100.0 \n", "1 100.0 100.0 100.0 \n", "2 100.0 100.0 98.7 \n", "3 100.0 100.0 100.0 \n", "4 97.8 81.2 100.0 \n", "\n", " International Faculty International Students Citations per Faculty \\\n", "0 100 94.1 99.8 \n", "1 99.8 67.7 98.6 \n", "2 86.3 62.2 99.6 \n", "3 99.7 98.5 84.7 \n", "4 99.4 87.3 100.0 \n", "\n", " Overall Score Free \n", "0 100.0 免费评估 \n", "1 98.4 免费评估 \n", "2 97.4 免费评估 \n", "3 97.2 免费评估 \n", "4 96.9 免费评估 " ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "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>Ranking</th>\n", " <th>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Academic Reputation</th>\n", " <th>Employer Reputation</th>\n", " <th>Faculty Student</th>\n", " <th>International Faculty</th>\n", " <th>International Students</th>\n", " <th>Citations per Faculty</th>\n", " <th>Overall Score</th>\n", " <th>Free</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>497</th>\n", " <td>498</td>\n", " <td>Czech Technical University in Prague</td>\n", " <td>Czech Republic</td>\n", " <td>18.7</td>\n", " <td>39.7</td>\n", " <td>33.9</td>\n", " <td>18.2</td>\n", " <td>57.5</td>\n", " <td>10.6</td>\n", " <td>24.2</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>498</th>\n", " <td>498</td>\n", " <td>Université de Montpellier</td>\n", " <td>France</td>\n", " <td>20.3</td>\n", " <td>18.8</td>\n", " <td>13.1</td>\n", " <td>20.1</td>\n", " <td>39.3</td>\n", " <td>42.8</td>\n", " <td>24.2</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>499</th>\n", " <td>498</td>\n", " <td>University of Eastern Finland</td>\n", " <td>Finland</td>\n", " <td>14.5</td>\n", " <td>10.5</td>\n", " <td>43.8</td>\n", " <td>27.9</td>\n", " <td>9.1</td>\n", " <td>33.5</td>\n", " <td>24.2</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Ranking University English Name Country/Region \\\n", "497 498 Czech Technical University in Prague Czech Republic \n", "498 498 Université de Montpellier France \n", "499 498 University of Eastern Finland Finland \n", "\n", " Academic Reputation Employer Reputation Faculty Student \\\n", "497 18.7 39.7 33.9 \n", "498 20.3 18.8 13.1 \n", "499 14.5 10.5 43.8 \n", "\n", " International Faculty International Students Citations per Faculty \\\n", "497 18.2 57.5 10.6 \n", "498 20.1 39.3 42.8 \n", "499 27.9 9.1 33.5 \n", "\n", " Overall Score Free \n", "497 24.2 免费评估 \n", "498 24.2 免费评估 \n", "499 24.2 免费评估 " ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.tail(3)" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Ranking', 'University English Name', 'Country/Region',\n", " 'Academic Reputation', 'Employer Reputation', 'Faculty Student',\n", " 'International Faculty', 'International Students',\n", " 'Citations per Faculty', 'Overall Score', 'Free'],\n", " dtype='object')" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#标签\n", "df.columns" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "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>0</th>\n", " <th>1</th>\n", " <th>2</th>\n", " <th>3</th>\n", " <th>4</th>\n", " <th>5</th>\n", " <th>6</th>\n", " <th>7</th>\n", " <th>8</th>\n", " <th>9</th>\n", " <th>...</th>\n", " <th>490</th>\n", " <th>491</th>\n", " <th>492</th>\n", " <th>493</th>\n", " <th>494</th>\n", " <th>495</th>\n", " <th>496</th>\n", " <th>497</th>\n", " <th>498</th>\n", " <th>499</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>Ranking</th>\n", " <td>1</td>\n", " <td>2</td>\n", " <td>3</td>\n", " <td>4</td>\n", " <td>5</td>\n", " <td>6</td>\n", " <td>7</td>\n", " <td>8</td>\n", " <td>9</td>\n", " <td>10</td>\n", " <td>...</td>\n", " <td>491</td>\n", " <td>491</td>\n", " <td>491</td>\n", " <td>491</td>\n", " <td>491</td>\n", " <td>491</td>\n", " <td>491</td>\n", " <td>498</td>\n", " <td>498</td>\n", " <td>498</td>\n", " </tr>\n", " <tr>\n", " <th>University English Name</th>\n", " <td>麻省理工学院Massachusetts Institute of Technology</td>\n", " <td>斯坦福大学Stanford University</td>\n", " <td>哈佛大学Harvard University</td>\n", " <td>牛津大学University of Oxford</td>\n", " <td>加利福尼亚理工学院California Institute of Technology</td>\n", " <td>ETH Zurich - Swiss Federal Institute of Techno...</td>\n", " <td>剑桥大学University of Cambridge</td>\n", " <td>伦敦大学学院University College London</td>\n", " <td>帝国理工学院Imperial College London</td>\n", " <td>芝加哥大学The University of Chicago</td>\n", " <td>...</td>\n", " <td>Indian Institute of Technology Guwahati (IITG)</td>\n", " <td>Lappeenranta-Lahti University of Technology LUT</td>\n", " <td>Auezov South Kazakhstan State University (SKSU)</td>\n", " <td>Universidad de Montevideo (UM)</td>\n", " <td>Aix-Marseille University</td>\n", " <td>特拉华大学University of Delaware</td>\n", " <td>V. N. Karazin Kharkiv National University</td>\n", " <td>Czech Technical University in Prague</td>\n", " <td>Université de Montpellier</td>\n", " <td>University of Eastern Finland</td>\n", " </tr>\n", " <tr>\n", " <th>Country/Region</th>\n", " <td>United States</td>\n", " <td>United States</td>\n", " <td>United States</td>\n", " <td>United Kingdom</td>\n", " <td>United States</td>\n", " <td>Switzerland</td>\n", " <td>United Kingdom</td>\n", " <td>United Kingdom</td>\n", " <td>United Kingdom</td>\n", " <td>United States</td>\n", " <td>...</td>\n", " <td>India</td>\n", " <td>Finland</td>\n", " <td>Kazakhstan</td>\n", " <td>Uruguay</td>\n", " <td>France</td>\n", " <td>United States</td>\n", " <td>Ukraine</td>\n", " <td>Czech Republic</td>\n", " <td>France</td>\n", " <td>Finland</td>\n", " </tr>\n", " <tr>\n", " <th>Academic Reputation</th>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>97.8</td>\n", " <td>98.4</td>\n", " <td>100</td>\n", " <td>99.3</td>\n", " <td>98.6</td>\n", " <td>99.5</td>\n", " <td>...</td>\n", " <td>11.7</td>\n", " <td>6.6</td>\n", " <td>7</td>\n", " <td>13.4</td>\n", " <td>33.9</td>\n", " <td>11</td>\n", " <td>10.8</td>\n", " <td>18.7</td>\n", " <td>20.3</td>\n", " <td>14.5</td>\n", " </tr>\n", " <tr>\n", " <th>Employer Reputation</th>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>81.2</td>\n", " <td>96.7</td>\n", " <td>100</td>\n", " <td>98.7</td>\n", " <td>99.9</td>\n", " <td>93.7</td>\n", " <td>...</td>\n", " <td>15.2</td>\n", " <td>17.2</td>\n", " <td>6.1</td>\n", " <td>17.3</td>\n", " <td>4.9</td>\n", " <td>10.2</td>\n", " <td>11.4</td>\n", " <td>39.7</td>\n", " <td>18.8</td>\n", " <td>10.5</td>\n", " </tr>\n", " <tr>\n", " <th>Faculty Student</th>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>98.7</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>85</td>\n", " <td>100</td>\n", " <td>98.1</td>\n", " <td>99.8</td>\n", " <td>96.5</td>\n", " <td>...</td>\n", " <td>18.7</td>\n", " <td>23.6</td>\n", " <td>94.1</td>\n", " <td>79.1</td>\n", " <td>13.5</td>\n", " <td>11.6</td>\n", " <td>72.2</td>\n", " <td>33.9</td>\n", " <td>13.1</td>\n", " <td>43.8</td>\n", " </tr>\n", " <tr>\n", " <th>International Faculty</th>\n", " <td>100</td>\n", " <td>99.8</td>\n", " <td>86.3</td>\n", " <td>99.7</td>\n", " <td>99.4</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>99.1</td>\n", " <td>100</td>\n", " <td>70.2</td>\n", " <td>...</td>\n", " <td>-</td>\n", " <td>49.4</td>\n", " <td>17.1</td>\n", " <td>18.1</td>\n", " <td>23.6</td>\n", " <td>39.3</td>\n", " <td>1.3</td>\n", " <td>18.2</td>\n", " <td>20.1</td>\n", " <td>27.9</td>\n", " </tr>\n", " <tr>\n", " <th>International Students</th>\n", " <td>94.1</td>\n", " <td>67.7</td>\n", " <td>62.2</td>\n", " <td>98.5</td>\n", " <td>87.3</td>\n", " <td>98</td>\n", " <td>97.6</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>81</td>\n", " <td>...</td>\n", " <td>1.5</td>\n", " <td>28.6</td>\n", " <td>17.7</td>\n", " <td>3.7</td>\n", " <td>26.6</td>\n", " <td>22.5</td>\n", " <td>78.4</td>\n", " <td>57.5</td>\n", " <td>39.3</td>\n", " <td>9.1</td>\n", " </tr>\n", " <tr>\n", " <th>Citations per Faculty</th>\n", " <td>99.8</td>\n", " <td>98.6</td>\n", " <td>99.6</td>\n", " <td>84.7</td>\n", " <td>100</td>\n", " <td>98.4</td>\n", " <td>74.2</td>\n", " <td>76.7</td>\n", " <td>72.1</td>\n", " <td>78.5</td>\n", " <td>...</td>\n", " <td>71.2</td>\n", " <td>56.3</td>\n", " <td>1</td>\n", " <td>1.3</td>\n", " <td>25</td>\n", " <td>67.1</td>\n", " <td>1.8</td>\n", " <td>10.6</td>\n", " <td>42.8</td>\n", " <td>33.5</td>\n", " </tr>\n", " <tr>\n", " <th>Overall Score</th>\n", " <td>100</td>\n", " <td>98.4</td>\n", " <td>97.4</td>\n", " <td>97.2</td>\n", " <td>96.9</td>\n", " <td>95.9</td>\n", " <td>95</td>\n", " <td>94.8</td>\n", " <td>94.1</td>\n", " <td>92</td>\n", " <td>...</td>\n", " <td>24.3</td>\n", " <td>24.3</td>\n", " <td>24.3</td>\n", " <td>24.3</td>\n", " <td>24.3</td>\n", " <td>24.3</td>\n", " <td>24.3</td>\n", " <td>24.2</td>\n", " <td>24.2</td>\n", " <td>24.2</td>\n", " </tr>\n", " <tr>\n", " <th>Free</th>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>...</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>11 rows × 500 columns</p>\n", "</div>" ], "text/plain": [ " 0 \\\n", "Ranking 1 \n", "University English Name 麻省理工学院Massachusetts Institute of Technology \n", "Country/Region United States \n", "Academic Reputation 100 \n", "Employer Reputation 100 \n", "Faculty Student 100 \n", "International Faculty 100 \n", "International Students 94.1 \n", "Citations per Faculty 99.8 \n", "Overall Score 100 \n", "Free 免费评估 \n", "\n", " 1 2 \\\n", "Ranking 2 3 \n", "University English Name 斯坦福大学Stanford University 哈佛大学Harvard University \n", "Country/Region United States United States \n", "Academic Reputation 100 100 \n", "Employer Reputation 100 100 \n", "Faculty Student 100 98.7 \n", "International Faculty 99.8 86.3 \n", "International Students 67.7 62.2 \n", "Citations per Faculty 98.6 99.6 \n", "Overall Score 98.4 97.4 \n", "Free 免费评估 免费评估 \n", "\n", " 3 \\\n", "Ranking 4 \n", "University English Name 牛津大学University of Oxford \n", "Country/Region United Kingdom \n", "Academic Reputation 100 \n", "Employer Reputation 100 \n", "Faculty Student 100 \n", "International Faculty 99.7 \n", "International Students 98.5 \n", "Citations per Faculty 84.7 \n", "Overall Score 97.2 \n", "Free 免费评估 \n", "\n", " 4 \\\n", "Ranking 5 \n", "University English Name 加利福尼亚理工学院California Institute of Technology \n", "Country/Region United States \n", "Academic Reputation 97.8 \n", "Employer Reputation 81.2 \n", "Faculty Student 100 \n", "International Faculty 99.4 \n", "International Students 87.3 \n", "Citations per Faculty 100 \n", "Overall Score 96.9 \n", "Free 免费评估 \n", "\n", " 5 \\\n", "Ranking 6 \n", "University English Name ETH Zurich - Swiss Federal Institute of Techno... \n", "Country/Region Switzerland \n", "Academic Reputation 98.4 \n", "Employer Reputation 96.7 \n", "Faculty Student 85 \n", "International Faculty 100 \n", "International Students 98 \n", "Citations per Faculty 98.4 \n", "Overall Score 95.9 \n", "Free 免费评估 \n", "\n", " 6 \\\n", "Ranking 7 \n", "University English Name 剑桥大学University of Cambridge \n", "Country/Region United Kingdom \n", "Academic Reputation 100 \n", "Employer Reputation 100 \n", "Faculty Student 100 \n", "International Faculty 100 \n", "International Students 97.6 \n", "Citations per Faculty 74.2 \n", "Overall Score 95 \n", "Free 免费评估 \n", "\n", " 7 \\\n", "Ranking 8 \n", "University English Name 伦敦大学学院University College London \n", "Country/Region United Kingdom \n", "Academic Reputation 99.3 \n", "Employer Reputation 98.7 \n", "Faculty Student 98.1 \n", "International Faculty 99.1 \n", "International Students 100 \n", "Citations per Faculty 76.7 \n", "Overall Score 94.8 \n", "Free 免费评估 \n", "\n", " 8 \\\n", "Ranking 9 \n", "University English Name 帝国理工学院Imperial College London \n", "Country/Region United Kingdom \n", "Academic Reputation 98.6 \n", "Employer Reputation 99.9 \n", "Faculty Student 99.8 \n", "International Faculty 100 \n", "International Students 100 \n", "Citations per Faculty 72.1 \n", "Overall Score 94.1 \n", "Free 免费评估 \n", "\n", " 9 ... \\\n", "Ranking 10 ... \n", "University English Name 芝加哥大学The University of Chicago ... \n", "Country/Region United States ... \n", "Academic Reputation 99.5 ... \n", "Employer Reputation 93.7 ... \n", "Faculty Student 96.5 ... \n", "International Faculty 70.2 ... \n", "International Students 81 ... \n", "Citations per Faculty 78.5 ... \n", "Overall Score 92 ... \n", "Free 免费评估 ... \n", "\n", " 490 \\\n", "Ranking 491 \n", "University English Name Indian Institute of Technology Guwahati (IITG) \n", "Country/Region India \n", "Academic Reputation 11.7 \n", "Employer Reputation 15.2 \n", "Faculty Student 18.7 \n", "International Faculty - \n", "International Students 1.5 \n", "Citations per Faculty 71.2 \n", "Overall Score 24.3 \n", "Free 免费评估 \n", "\n", " 491 \\\n", "Ranking 491 \n", "University English Name Lappeenranta-Lahti University of Technology LUT \n", "Country/Region Finland \n", "Academic Reputation 6.6 \n", "Employer Reputation 17.2 \n", "Faculty Student 23.6 \n", "International Faculty 49.4 \n", "International Students 28.6 \n", "Citations per Faculty 56.3 \n", "Overall Score 24.3 \n", "Free 免费评估 \n", "\n", " 492 \\\n", "Ranking 491 \n", "University English Name Auezov South Kazakhstan State University (SKSU) \n", "Country/Region Kazakhstan \n", "Academic Reputation 7 \n", "Employer Reputation 6.1 \n", "Faculty Student 94.1 \n", "International Faculty 17.1 \n", "International Students 17.7 \n", "Citations per Faculty 1 \n", "Overall Score 24.3 \n", "Free 免费评估 \n", "\n", " 493 \\\n", "Ranking 491 \n", "University English Name Universidad de Montevideo (UM) \n", "Country/Region Uruguay \n", "Academic Reputation 13.4 \n", "Employer Reputation 17.3 \n", "Faculty Student 79.1 \n", "International Faculty 18.1 \n", "International Students 3.7 \n", "Citations per Faculty 1.3 \n", "Overall Score 24.3 \n", "Free 免费评估 \n", "\n", " 494 \\\n", "Ranking 491 \n", "University English Name Aix-Marseille University \n", "Country/Region France \n", "Academic Reputation 33.9 \n", "Employer Reputation 4.9 \n", "Faculty Student 13.5 \n", "International Faculty 23.6 \n", "International Students 26.6 \n", "Citations per Faculty 25 \n", "Overall Score 24.3 \n", "Free 免费评估 \n", "\n", " 495 \\\n", "Ranking 491 \n", "University English Name 特拉华大学University of Delaware \n", "Country/Region United States \n", "Academic Reputation 11 \n", "Employer Reputation 10.2 \n", "Faculty Student 11.6 \n", "International Faculty 39.3 \n", "International Students 22.5 \n", "Citations per Faculty 67.1 \n", "Overall Score 24.3 \n", "Free 免费评估 \n", "\n", " 496 \\\n", "Ranking 491 \n", "University English Name V. N. Karazin Kharkiv National University \n", "Country/Region Ukraine \n", "Academic Reputation 10.8 \n", "Employer Reputation 11.4 \n", "Faculty Student 72.2 \n", "International Faculty 1.3 \n", "International Students 78.4 \n", "Citations per Faculty 1.8 \n", "Overall Score 24.3 \n", "Free 免费评估 \n", "\n", " 497 \\\n", "Ranking 498 \n", "University English Name Czech Technical University in Prague \n", "Country/Region Czech Republic \n", "Academic Reputation 18.7 \n", "Employer Reputation 39.7 \n", "Faculty Student 33.9 \n", "International Faculty 18.2 \n", "International Students 57.5 \n", "Citations per Faculty 10.6 \n", "Overall Score 24.2 \n", "Free 免费评估 \n", "\n", " 498 \\\n", "Ranking 498 \n", "University English Name Université de Montpellier \n", "Country/Region France \n", "Academic Reputation 20.3 \n", "Employer Reputation 18.8 \n", "Faculty Student 13.1 \n", "International Faculty 20.1 \n", "International Students 39.3 \n", "Citations per Faculty 42.8 \n", "Overall Score 24.2 \n", "Free 免费评估 \n", "\n", " 499 \n", "Ranking 498 \n", "University English Name University of Eastern Finland \n", "Country/Region Finland \n", "Academic Reputation 14.5 \n", "Employer Reputation 10.5 \n", "Faculty Student 43.8 \n", "International Faculty 27.9 \n", "International Students 9.1 \n", "Citations per Faculty 33.5 \n", "Overall Score 24.2 \n", "Free 免费评估 \n", "\n", "[11 rows x 500 columns]" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#矩阵倒置\n", "df.T" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "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>Ranking</th>\n", " <th>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Academic Reputation</th>\n", " <th>Employer Reputation</th>\n", " <th>Faculty Student</th>\n", " <th>International Faculty</th>\n", " <th>International Students</th>\n", " <th>Citations per Faculty</th>\n", " <th>Overall Score</th>\n", " <th>Free</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>385</th>\n", " <td>383</td>\n", " <td>Universidad de Palermo (UP)</td>\n", " <td>Argentina</td>\n", " <td>9.8</td>\n", " <td>9.6</td>\n", " <td>84.6</td>\n", " <td>35.1</td>\n", " <td>97.5</td>\n", " <td>1.2</td>\n", " <td>28.8</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>437</th>\n", " <td>438</td>\n", " <td>Universidad de Belgrano</td>\n", " <td>Argentina</td>\n", " <td>7.7</td>\n", " <td>19.0</td>\n", " <td>89.2</td>\n", " <td>6.9</td>\n", " <td>55.8</td>\n", " <td>1.1</td>\n", " <td>26.3</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>73</th>\n", " <td>74</td>\n", " <td>Universidad de Buenos Aires (UBA)</td>\n", " <td>Argentina</td>\n", " <td>87.2</td>\n", " <td>91.3</td>\n", " <td>77.4</td>\n", " <td>50.7</td>\n", " <td>64.7</td>\n", " <td>2.4</td>\n", " <td>66.0</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>402</th>\n", " <td>400</td>\n", " <td>Universidad Austral</td>\n", " <td>Argentina</td>\n", " <td>15.6</td>\n", " <td>36.9</td>\n", " <td>84.4</td>\n", " <td>6.1</td>\n", " <td>12.2</td>\n", " <td>1.9</td>\n", " <td>28.2</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>344</th>\n", " <td>344</td>\n", " <td>Pontificia Universidad Católica Argentina</td>\n", " <td>Argentina</td>\n", " <td>17.7</td>\n", " <td>44.3</td>\n", " <td>95.3</td>\n", " <td>2.9</td>\n", " <td>13.2</td>\n", " <td>1.1</td>\n", " <td>31.7</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Ranking University English Name Country/Region \\\n", "385 383 Universidad de Palermo (UP) Argentina \n", "437 438 Universidad de Belgrano Argentina \n", "73 74 Universidad de Buenos Aires (UBA) Argentina \n", "402 400 Universidad Austral Argentina \n", "344 344 Pontificia Universidad Católica Argentina Argentina \n", "\n", " Academic Reputation Employer Reputation Faculty Student \\\n", "385 9.8 9.6 84.6 \n", "437 7.7 19.0 89.2 \n", "73 87.2 91.3 77.4 \n", "402 15.6 36.9 84.4 \n", "344 17.7 44.3 95.3 \n", "\n", " International Faculty International Students Citations per Faculty \\\n", "385 35.1 97.5 1.2 \n", "437 6.9 55.8 1.1 \n", "73 50.7 64.7 2.4 \n", "402 6.1 12.2 1.9 \n", "344 2.9 13.2 1.1 \n", "\n", " Overall Score Free \n", "385 28.8 免费评估 \n", "437 26.3 免费评估 \n", "73 66.0 免费评估 \n", "402 28.2 免费评估 \n", "344 31.7 免费评估 " ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#按值排序\n", "df.sort_values(by='Country/Region').head()" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "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>Ranking</th>\n", " <th>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Academic Reputation</th>\n", " <th>Employer Reputation</th>\n", " <th>Faculty Student</th>\n", " <th>International Faculty</th>\n", " <th>International Students</th>\n", " <th>Citations per Faculty</th>\n", " <th>Overall Score</th>\n", " <th>Free</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>1</td>\n", " <td>麻省理工学院Massachusetts Institute of Technology</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100</td>\n", " <td>94.1</td>\n", " <td>99.8</td>\n", " <td>100.0</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>2</td>\n", " <td>斯坦福大学Stanford University</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>99.8</td>\n", " <td>67.7</td>\n", " <td>98.6</td>\n", " <td>98.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Ranking University English Name Country/Region \\\n", "0 1 麻省理工学院Massachusetts Institute of Technology United States \n", "1 2 斯坦福大学Stanford University United States \n", "\n", " Academic Reputation Employer Reputation Faculty Student \\\n", "0 100.0 100.0 100.0 \n", "1 100.0 100.0 100.0 \n", "\n", " International Faculty International Students Citations per Faculty \\\n", "0 100 94.1 99.8 \n", "1 99.8 67.7 98.6 \n", "\n", " Overall Score Free \n", "0 100.0 免费评估 \n", "1 98.4 免费评估 " ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#行切片\n", "df[:2]" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "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>Ranking</th>\n", " <th>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Academic Reputation</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>1</td>\n", " <td>麻省理工学院Massachusetts Institute of Technology</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>2</td>\n", " <td>斯坦福大学Stanford University</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Ranking University English Name Country/Region \\\n", "0 1 麻省理工学院Massachusetts Institute of Technology United States \n", "1 2 斯坦福大学Stanford University United States \n", "\n", " Academic Reputation \n", "0 100.0 \n", "1 100.0 " ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#行、列切片\n", "df.iloc[:2, :4]" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "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>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Free</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>麻省理工学院Massachusetts Institute of Technology</td>\n", " <td>United States</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>斯坦福大学Stanford University</td>\n", " <td>United States</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " University English Name Country/Region Free\n", "0 麻省理工学院Massachusetts Institute of Technology United States 免费评估\n", "1 斯坦福大学Stanford University United States 免费评估" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#选择固定列\n", "df.iloc[:2, [1, 2, -1]]" ] }, { "cell_type": "code", "execution_count": 66, "metadata": {}, "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>Ranking</th>\n", " <th>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Academic Reputation</th>\n", " <th>Employer Reputation</th>\n", " <th>Faculty Student</th>\n", " <th>International Faculty</th>\n", " <th>International Students</th>\n", " <th>Citations per Faculty</th>\n", " <th>Overall Score</th>\n", " <th>Free</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>1</td>\n", " <td>麻省理工学院Massachusetts Institute of Technology</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100</td>\n", " <td>94.1</td>\n", " <td>99.8</td>\n", " <td>100.0</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>2</td>\n", " <td>斯坦福大学Stanford University</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>99.8</td>\n", " <td>67.7</td>\n", " <td>98.6</td>\n", " <td>98.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>3</td>\n", " <td>哈佛大学Harvard University</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>98.7</td>\n", " <td>86.3</td>\n", " <td>62.2</td>\n", " <td>99.6</td>\n", " <td>97.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>7</th>\n", " <td>8</td>\n", " <td>伦敦大学学院University College London</td>\n", " <td>United Kingdom</td>\n", " <td>99.3</td>\n", " <td>98.7</td>\n", " <td>98.1</td>\n", " <td>99.1</td>\n", " <td>100</td>\n", " <td>76.7</td>\n", " <td>94.8</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>8</th>\n", " <td>9</td>\n", " <td>帝国理工学院Imperial College London</td>\n", " <td>United Kingdom</td>\n", " <td>98.6</td>\n", " <td>99.9</td>\n", " <td>99.8</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>72.1</td>\n", " <td>94.1</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>17</th>\n", " <td>18</td>\n", " <td>哥伦比亚大学Columbia University</td>\n", " <td>United States</td>\n", " <td>99.7</td>\n", " <td>97.6</td>\n", " <td>100.0</td>\n", " <td>40.1</td>\n", " <td>96.9</td>\n", " <td>53.0</td>\n", " <td>87.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>18</th>\n", " <td>18</td>\n", " <td>EPFL - Ecole Polytechnique Federale de Lausanne</td>\n", " <td>Switzerland</td>\n", " <td>75.6</td>\n", " <td>77.6</td>\n", " <td>96.6</td>\n", " <td>100</td>\n", " <td>100</td>\n", " <td>98.9</td>\n", " <td>87.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>19</th>\n", " <td>20</td>\n", " <td>爱丁堡大学The University of Edinburgh</td>\n", " <td>United Kingdom</td>\n", " <td>97.5</td>\n", " <td>93.7</td>\n", " <td>85.6</td>\n", " <td>98</td>\n", " <td>98.6</td>\n", " <td>53.0</td>\n", " <td>86.2</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>20</th>\n", " <td>21</td>\n", " <td>密歇根大学安娜堡分校University of Michigan,Ann Arbor</td>\n", " <td>United States</td>\n", " <td>98.9</td>\n", " <td>94.4</td>\n", " <td>91.0</td>\n", " <td>79.7</td>\n", " <td>44.1</td>\n", " <td>61.6</td>\n", " <td>86.0</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>21</th>\n", " <td>22</td>\n", " <td>Peking University</td>\n", " <td>China</td>\n", " <td>99.1</td>\n", " <td>99.6</td>\n", " <td>72.3</td>\n", " <td>70.7</td>\n", " <td>36.9</td>\n", " <td>73.0</td>\n", " <td>84.3</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Ranking University English Name Country/Region \\\n", "0 1 麻省理工学院Massachusetts Institute of Technology United States \n", "1 2 斯坦福大学Stanford University United States \n", "2 3 哈佛大学Harvard University United States \n", "7 8 伦敦大学学院University College London United Kingdom \n", "8 9 帝国理工学院Imperial College London United Kingdom \n", "17 18 哥伦比亚大学Columbia University United States \n", "18 18 EPFL - Ecole Polytechnique Federale de Lausanne Switzerland \n", "19 20 爱丁堡大学The University of Edinburgh United Kingdom \n", "20 21 密歇根大学安娜堡分校University of Michigan,Ann Arbor United States \n", "21 22 Peking University China \n", "\n", " Academic Reputation Employer Reputation Faculty Student \\\n", "0 100.0 100.0 100.0 \n", "1 100.0 100.0 100.0 \n", "2 100.0 100.0 98.7 \n", "7 99.3 98.7 98.1 \n", "8 98.6 99.9 99.8 \n", "17 99.7 97.6 100.0 \n", "18 75.6 77.6 96.6 \n", "19 97.5 93.7 85.6 \n", "20 98.9 94.4 91.0 \n", "21 99.1 99.6 72.3 \n", "\n", " International Faculty International Students Citations per Faculty \\\n", "0 100 94.1 99.8 \n", "1 99.8 67.7 98.6 \n", "2 86.3 62.2 99.6 \n", "7 99.1 100 76.7 \n", "8 100 100 72.1 \n", "17 40.1 96.9 53.0 \n", "18 100 100 98.9 \n", "19 98 98.6 53.0 \n", "20 79.7 44.1 61.6 \n", "21 70.7 36.9 73.0 \n", "\n", " Overall Score Free \n", "0 100.0 免费评估 \n", "1 98.4 免费评估 \n", "2 97.4 免费评估 \n", "7 94.8 免费评估 \n", "8 94.1 免费评估 \n", "17 87.4 免费评估 \n", "18 87.4 免费评估 \n", "19 86.2 免费评估 \n", "20 86.0 免费评估 \n", "21 84.3 免费评估 " ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#表格记录合并\n", "pieces = [ df[:3], df[7:9], df[17: 22] ]\n", "df_new = pd.concat(pieces)\n", "df_new" ] }, { "cell_type": "code", "execution_count": 81, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/nuoxinkeji/Library/Python/3.7/lib/python/site-packages/ipykernel_launcher.py:2: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n", " \n" ] }, { "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>Ranking</th>\n", " <th>University English Name</th>\n", " <th>Country/Region</th>\n", " <th>Academic Reputation</th>\n", " <th>Employer Reputation</th>\n", " <th>Faculty Student</th>\n", " <th>International Faculty</th>\n", " <th>International Students</th>\n", " <th>Citations per Faculty</th>\n", " <th>Overall Score</th>\n", " <th>Free</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>1</td>\n", " <td>麻省理工学院Massachusetts Institute of Technology</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>100</td>\n", " <td>94.1</td>\n", " <td>99.8</td>\n", " <td>100.0</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>3</td>\n", " <td>哈佛大学Harvard University</td>\n", " <td>United States</td>\n", " <td>100.0</td>\n", " <td>100.0</td>\n", " <td>98.7</td>\n", " <td>86.3</td>\n", " <td>62.2</td>\n", " <td>99.6</td>\n", " <td>97.4</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>5</td>\n", " <td>加利福尼亚理工学院California Institute of Technology</td>\n", " <td>United States</td>\n", " <td>97.8</td>\n", " <td>81.2</td>\n", " <td>100.0</td>\n", " <td>99.4</td>\n", " <td>87.3</td>\n", " <td>100.0</td>\n", " <td>96.9</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>12</th>\n", " <td>13</td>\n", " <td>普林斯顿大学Princeton University</td>\n", " <td>United States</td>\n", " <td>99.9</td>\n", " <td>98.6</td>\n", " <td>70.7</td>\n", " <td>64.9</td>\n", " <td>67.6</td>\n", " <td>100.0</td>\n", " <td>90.9</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>67</th>\n", " <td>68</td>\n", " <td>西雅图华盛顿大学University of Washington,Seattle Campus</td>\n", " <td>United States</td>\n", " <td>86.1</td>\n", " <td>51.4</td>\n", " <td>17.4</td>\n", " <td>55.8</td>\n", " <td>40.5</td>\n", " <td>99.2</td>\n", " <td>67.9</td>\n", " <td>免费评估</td>\n", " </tr>\n", " <tr>\n", " <th>71</th>\n", " <td>72</td>\n", " <td>佐治亚理工学院Georgia Institute of Technology</td>\n", " <td>United States</td>\n", " <td>71.1</td>\n", " <td>81.7</td>\n", " <td>15.1</td>\n", " <td>60.4</td>\n", " <td>65.8</td>\n", " <td>100.0</td>\n", " <td>66.2</td>\n", " <td>免费评估</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Ranking University English Name Country/Region \\\n", "0 1 麻省理工学院Massachusetts Institute of Technology United States \n", "2 3 哈佛大学Harvard University United States \n", "4 5 加利福尼亚理工学院California Institute of Technology United States \n", "12 13 普林斯顿大学Princeton University United States \n", "67 68 西雅图华盛顿大学University of Washington,Seattle Campus United States \n", "71 72 佐治亚理工学院Georgia Institute of Technology United States \n", "\n", " Academic Reputation Employer Reputation Faculty Student \\\n", "0 100.0 100.0 100.0 \n", "2 100.0 100.0 98.7 \n", "4 97.8 81.2 100.0 \n", "12 99.9 98.6 70.7 \n", "67 86.1 51.4 17.4 \n", "71 71.1 81.7 15.1 \n", "\n", " International Faculty International Students Citations per Faculty \\\n", "0 100 94.1 99.8 \n", "2 86.3 62.2 99.6 \n", "4 99.4 87.3 100.0 \n", "12 64.9 67.6 100.0 \n", "67 55.8 40.5 99.2 \n", "71 60.4 65.8 100.0 \n", "\n", " Overall Score Free \n", "0 100.0 免费评估 \n", "2 97.4 免费评估 \n", "4 96.9 免费评估 \n", "12 90.9 免费评估 \n", "67 67.9 免费评估 \n", "71 66.2 免费评估 " ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#数据筛选: 赛选条件[]可以无限\n", "df[ df['Citations per Faculty'] > 99][ df['Country/Region'] == 'United States' ]" ] }, { "cell_type": "code", "execution_count": 97, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Argentina 5\n", "Australia 26\n", "Austria 5\n", "Belarus 1\n", "Belgium 7\n", "Brazil 5\n", "Brunei 2\n", "Canada 17\n", "Chile 3\n", "China 24\n", "Colombia 4\n", "Czech Republic 3\n", "Denmark 5\n", "Egypt 1\n", "Estonia 1\n", "Finland 8\n", "France 17\n", "Germany 29\n", "Greece 1\n", "Hong Kong 6\n", "India 9\n", "Indonesia 3\n", "Iran, Islamic Republic of 2\n", "Ireland 5\n", "Israel 4\n", "Italy 12\n", "Japan 17\n", "Kazakhstan 3\n", "Lebanon 1\n", "Lithuania 1\n", "Macao 1\n", "Malaysia 7\n", "Mexico 2\n", "Netherlands 13\n", "New Zealand 8\n", "Norway 4\n", "Oman 1\n", "Pakistan 2\n", "Peru 1\n", "Philippines 1\n", "Poland 2\n", "Portugal 4\n", "Qatar 1\n", "Russia 16\n", "Saudi Arabia 3\n", "Singapore 3\n", "South Africa 3\n", "South Korea 15\n", "Spain 12\n", "Sweden 8\n", "Switzerland 8\n", "Taiwan 11\n", "Thailand 2\n", "Turkey 1\n", "Ukraine 1\n", "United Arab Emirates 3\n", "United Kingdom 50\n", "United States 89\n", "Uruguay 1\n" ] } ], "source": [ "#分组:统计各个国家学校个数\n", "for name, group in df.groupby('Country/Region'):\n", " print(name, len(group))" ] }, { "cell_type": "code", "execution_count": 99, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[1, '麻省理工学院Massachusetts Institute of Technology',\n", " 'United States', ..., 99.8, 100.0, '免费评估'],\n", " [2, '斯坦福大学Stanford University', 'United States', ..., 98.6, 98.4,\n", " '免费评估'],\n", " [3, '哈佛大学Harvard University', 'United States', ..., 99.6, 97.4,\n", " '免费评估'],\n", " ...,\n", " [498, 'Czech Technical University in Prague', 'Czech Republic',\n", " ..., 10.6, 24.2, '免费评估'],\n", " [498, 'Université de Montpellier', 'France', ..., 42.8, 24.2,\n", " '免费评估'],\n", " [498, 'University of Eastern Finland', 'Finland', ..., 33.5, 24.2,\n", " '免费评估']], dtype=object)" ] }, "execution_count": 99, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#转换为numpy\n", "df.to_numpy()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7.3 64-bit", "language": "python", "name": "python37364bita178267b7104410b8f4fa90d927b8508" }, "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.5" } }, "nbformat": 4, "nbformat_minor": 4 }