Created
July 11, 2020 07:45
-
-
Save nikhilkumarsingh/c72944cabb8d571b744d25eff458840e to your computer and use it in GitHub Desktop.
Reading Wikipedia Tables using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Reading Wikipedia Tables using Python\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"> You might need to install `lxml` package to make `pd.read_html` method work. To install `lxml`, simply do:\n", | |
"> ```\n", | |
">pip install lxml\n", | |
">```" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"dfs = pd.read_html(\"https://en.wikipedia.org/wiki/List_of_international_cricket_centuries_by_Sachin_Tendulkar\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"6" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"len(dfs)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"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>Symbol</th>\n", | |
" <th>Meaning</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>*</td>\n", | |
" <td>Remained not out</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>NaN</td>\n", | |
" <td>Player of the match</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>NaN</td>\n", | |
" <td>Captained the Indian cricket team</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Test</td>\n", | |
" <td>The number of the Test match played in that se...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Pos.</td>\n", | |
" <td>Position in the batting order</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>Inn.</td>\n", | |
" <td>The innings of the match</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>S.R.</td>\n", | |
" <td>Strike rate during the innings</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>H/A/N</td>\n", | |
" <td>Venue was at home (India), away or neutral</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>Lost</td>\n", | |
" <td>The match was lost by India</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>Won</td>\n", | |
" <td>The match was won by India</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>Drawn</td>\n", | |
" <td>The match was drawn</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Symbol Meaning\n", | |
"0 * Remained not out\n", | |
"1 NaN Player of the match\n", | |
"2 NaN Captained the Indian cricket team\n", | |
"3 Test The number of the Test match played in that se...\n", | |
"4 Pos. Position in the batting order\n", | |
"5 Inn. The innings of the match\n", | |
"6 S.R. Strike rate during the innings\n", | |
"7 H/A/N Venue was at home (India), away or neutral\n", | |
"8 Lost The match was lost by India\n", | |
"9 Won The match was won by India\n", | |
"10 Drawn The match was drawn" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dfs[0]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"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>No.</th>\n", | |
" <th>Score</th>\n", | |
" <th>Against</th>\n", | |
" <th>Pos.</th>\n", | |
" <th>Inn.</th>\n", | |
" <th>Test</th>\n", | |
" <th>Venue</th>\n", | |
" <th>H/A</th>\n", | |
" <th>Date</th>\n", | |
" <th>Result</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>1</td>\n", | |
" <td>119*</td>\n", | |
" <td>England</td>\n", | |
" <td>6</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>Old Trafford, Manchester</td>\n", | |
" <td>Away</td>\n", | |
" <td>9 August 1990</td>\n", | |
" <td>Drawn[11]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>2</td>\n", | |
" <td>148*</td>\n", | |
" <td>Australia</td>\n", | |
" <td>6</td>\n", | |
" <td>2</td>\n", | |
" <td>3</td>\n", | |
" <td>Sydney Cricket Ground, Sydney</td>\n", | |
" <td>Away</td>\n", | |
" <td>2 January 1992</td>\n", | |
" <td>Drawn[12]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>3</td>\n", | |
" <td>114</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>5</td>\n", | |
" <td>WACA Ground, Perth</td>\n", | |
" <td>Away</td>\n", | |
" <td>1 February 1992</td>\n", | |
" <td>Lost[13]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>4</td>\n", | |
" <td>111</td>\n", | |
" <td>South Africa</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Wanderers Stadium, Johannesburg</td>\n", | |
" <td>Away</td>\n", | |
" <td>26 November 1992</td>\n", | |
" <td>Drawn[14]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>5</td>\n", | |
" <td>165</td>\n", | |
" <td>England</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>2</td>\n", | |
" <td>M. A. Chidambaram Stadium, Chennai</td>\n", | |
" <td>Home</td>\n", | |
" <td>11 February 1993</td>\n", | |
" <td>Won[15]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>6</td>\n", | |
" <td>104*</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" <td>Sinhalese Sports Club Ground, Colombo</td>\n", | |
" <td>Away</td>\n", | |
" <td>27 July 1993</td>\n", | |
" <td>Won[16]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>7</td>\n", | |
" <td>142</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>K. D. Singh Babu Stadium, Lucknow</td>\n", | |
" <td>Home</td>\n", | |
" <td>18 January 1994</td>\n", | |
" <td>Won[17]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>8</td>\n", | |
" <td>179</td>\n", | |
" <td>West Indies</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>2</td>\n", | |
" <td>Vidarbha Cricket Association Ground, Nagpur</td>\n", | |
" <td>Home</td>\n", | |
" <td>1 December 1994</td>\n", | |
" <td>Drawn[18]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>9</td>\n", | |
" <td>122</td>\n", | |
" <td>England</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>Edgbaston, Birmingham</td>\n", | |
" <td>Away</td>\n", | |
" <td>6 June 1996</td>\n", | |
" <td>Lost[19]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>10</td>\n", | |
" <td>177</td>\n", | |
" <td>England</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>Trent Bridge, Nottingham</td>\n", | |
" <td>Away</td>\n", | |
" <td>4 July 1996</td>\n", | |
" <td>Drawn[20]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>11</td>\n", | |
" <td>169</td>\n", | |
" <td>South Africa</td>\n", | |
" <td>5</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Newlands Cricket Ground, Cape Town</td>\n", | |
" <td>Away</td>\n", | |
" <td>2 January 1997</td>\n", | |
" <td>Lost[21]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>12</td>\n", | |
" <td>143</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>R. Premadasa Stadium, Colombo</td>\n", | |
" <td>Away</td>\n", | |
" <td>2 August 1997</td>\n", | |
" <td>Drawn[22]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>12</th>\n", | |
" <td>13</td>\n", | |
" <td>139</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Sinhalese Sports Club Ground, Colombo</td>\n", | |
" <td>Away</td>\n", | |
" <td>9 August 1997</td>\n", | |
" <td>Drawn[23]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>13</th>\n", | |
" <td>14</td>\n", | |
" <td>148</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>5</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>Wankhede Stadium, Mumbai</td>\n", | |
" <td>Home</td>\n", | |
" <td>3 December 1997</td>\n", | |
" <td>Drawn[24]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>14</th>\n", | |
" <td>15</td>\n", | |
" <td>155*</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>M. A. Chidambaram Stadium, Chennai</td>\n", | |
" <td>Home</td>\n", | |
" <td>6 March 1998</td>\n", | |
" <td>Won[25]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>16</td>\n", | |
" <td>177</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>M. Chinnaswamy Stadium, Bangalore</td>\n", | |
" <td>Home</td>\n", | |
" <td>25 March 1998</td>\n", | |
" <td>Lost[26]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>16</th>\n", | |
" <td>17</td>\n", | |
" <td>113</td>\n", | |
" <td>New Zealand</td>\n", | |
" <td>5</td>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" <td>Basin Reserve, Wellington</td>\n", | |
" <td>Away</td>\n", | |
" <td>26 December 1998</td>\n", | |
" <td>Lost[27]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>17</th>\n", | |
" <td>18</td>\n", | |
" <td>136</td>\n", | |
" <td>Pakistan</td>\n", | |
" <td>4</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>M. A. Chidambaram Stadium, Chennai</td>\n", | |
" <td>Home</td>\n", | |
" <td>28 January 1999</td>\n", | |
" <td>Lost[28]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>18</th>\n", | |
" <td>19</td>\n", | |
" <td>124*</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" <td>Sinhalese Sports Club Ground, Colombo</td>\n", | |
" <td>Away</td>\n", | |
" <td>24 February 1999</td>\n", | |
" <td>Drawn[29]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>19</th>\n", | |
" <td>20</td>\n", | |
" <td>126*</td>\n", | |
" <td>New Zealand</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>Punjab Cricket Association Stadium, Mohali</td>\n", | |
" <td>Home</td>\n", | |
" <td>10 October 1999</td>\n", | |
" <td>Drawn[30]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>20</th>\n", | |
" <td>21</td>\n", | |
" <td>217</td>\n", | |
" <td>New Zealand</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>Sardar Patel Stadium, Motera, Ahmedabad</td>\n", | |
" <td>Home</td>\n", | |
" <td>29 October 1999</td>\n", | |
" <td>Drawn[31]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>21</th>\n", | |
" <td>22</td>\n", | |
" <td>116</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Melbourne Cricket Ground, Melbourne</td>\n", | |
" <td>Away</td>\n", | |
" <td>26 December 1999</td>\n", | |
" <td>Lost[32]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>22</th>\n", | |
" <td>23</td>\n", | |
" <td>122</td>\n", | |
" <td>Zimbabwe</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>1</td>\n", | |
" <td>Feroz Shah Kotla, New Delhi</td>\n", | |
" <td>Home</td>\n", | |
" <td>18 November 2000</td>\n", | |
" <td>Won[33]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>23</th>\n", | |
" <td>24</td>\n", | |
" <td>201*</td>\n", | |
" <td>Zimbabwe</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>2</td>\n", | |
" <td>Vidarbha Cricket Association Ground, Nagpur</td>\n", | |
" <td>Home</td>\n", | |
" <td>25 November 2000</td>\n", | |
" <td>Drawn[34]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>24</th>\n", | |
" <td>25</td>\n", | |
" <td>126</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>3</td>\n", | |
" <td>M. A. Chidambaram Stadium, Chennai</td>\n", | |
" <td>Home</td>\n", | |
" <td>18 March 2001</td>\n", | |
" <td>Won[35]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25</th>\n", | |
" <td>26</td>\n", | |
" <td>155</td>\n", | |
" <td>South Africa</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>Goodyear Park, Bloemfontein</td>\n", | |
" <td>Away</td>\n", | |
" <td>3 November 2001</td>\n", | |
" <td>Lost[36]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>26</th>\n", | |
" <td>27</td>\n", | |
" <td>103</td>\n", | |
" <td>England</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Sardar Patel Stadium, Ahmedabad</td>\n", | |
" <td>Home</td>\n", | |
" <td>11 December 2001</td>\n", | |
" <td>Drawn[37]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>27</th>\n", | |
" <td>28</td>\n", | |
" <td>176</td>\n", | |
" <td>Zimbabwe</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>1</td>\n", | |
" <td>Vidarbha Cricket Association Ground, Nagpur</td>\n", | |
" <td>Home</td>\n", | |
" <td>21 February 2002</td>\n", | |
" <td>Won[38]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>28</th>\n", | |
" <td>29</td>\n", | |
" <td>117</td>\n", | |
" <td>West Indies</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>2</td>\n", | |
" <td>Queen's Park Oval, Port of Spain</td>\n", | |
" <td>Away</td>\n", | |
" <td>19 April 2002</td>\n", | |
" <td>Won[39]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>29</th>\n", | |
" <td>30</td>\n", | |
" <td>193</td>\n", | |
" <td>England</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>Headingley, Leeds</td>\n", | |
" <td>Away</td>\n", | |
" <td>22 August 2002</td>\n", | |
" <td>Won[40]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>30</th>\n", | |
" <td>31</td>\n", | |
" <td>176</td>\n", | |
" <td>West Indies</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>3</td>\n", | |
" <td>Eden Gardens, Kolkata</td>\n", | |
" <td>Home</td>\n", | |
" <td>30 October 2002</td>\n", | |
" <td>Drawn[41]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31</th>\n", | |
" <td>32</td>\n", | |
" <td>241*</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>4</td>\n", | |
" <td>Sydney Cricket Ground, Sydney</td>\n", | |
" <td>Away</td>\n", | |
" <td>2 January 2004</td>\n", | |
" <td>Drawn[42]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>32</th>\n", | |
" <td>33</td>\n", | |
" <td>194*</td>\n", | |
" <td>Pakistan</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>Multan Cricket Stadium, Multan</td>\n", | |
" <td>Away</td>\n", | |
" <td>28 March 2004</td>\n", | |
" <td>Won[43]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>33</th>\n", | |
" <td>34</td>\n", | |
" <td>248*</td>\n", | |
" <td>Bangladesh</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>1</td>\n", | |
" <td>Bangabandhu National Stadium, Dhaka</td>\n", | |
" <td>Away</td>\n", | |
" <td>10 December 2004</td>\n", | |
" <td>Won[44]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>34</th>\n", | |
" <td>35</td>\n", | |
" <td>109</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>2</td>\n", | |
" <td>Feroz Shah Kotla, New Delhi</td>\n", | |
" <td>Home</td>\n", | |
" <td>10 December 2005</td>\n", | |
" <td>Won[45]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>35</th>\n", | |
" <td>36</td>\n", | |
" <td>101</td>\n", | |
" <td>Bangladesh</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>Bir Shrestha Shahid Ruhul Amin Stadium, Chitta...</td>\n", | |
" <td>Away</td>\n", | |
" <td>18 May 2007</td>\n", | |
" <td>Drawn[46]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>36</th>\n", | |
" <td>37</td>\n", | |
" <td>122*</td>\n", | |
" <td>Bangladesh</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>2</td>\n", | |
" <td>Sher-e-Bangla National Stadium, Mirpur</td>\n", | |
" <td>Away</td>\n", | |
" <td>25 May 2007</td>\n", | |
" <td>Won[47]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>37</th>\n", | |
" <td>38</td>\n", | |
" <td>154*</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Sydney Cricket Ground, Sydney</td>\n", | |
" <td>Away</td>\n", | |
" <td>2 January 2008</td>\n", | |
" <td>Lost[48]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>38</th>\n", | |
" <td>39</td>\n", | |
" <td>153</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>4</td>\n", | |
" <td>Adelaide Oval, Adelaide</td>\n", | |
" <td>Away</td>\n", | |
" <td>24 January 2008</td>\n", | |
" <td>Drawn[49]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>39</th>\n", | |
" <td>40</td>\n", | |
" <td>109</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>4</td>\n", | |
" <td>Vidarbha Cricket Association Stadium, Nagpur</td>\n", | |
" <td>Home</td>\n", | |
" <td>6 November 2008</td>\n", | |
" <td>Won[50]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>40</th>\n", | |
" <td>41</td>\n", | |
" <td>103*</td>\n", | |
" <td>England</td>\n", | |
" <td>4</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>M. A. Chidambaram Stadium, Chennai</td>\n", | |
" <td>Home</td>\n", | |
" <td>11 December 2008</td>\n", | |
" <td>Won[51]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>41</th>\n", | |
" <td>42</td>\n", | |
" <td>160</td>\n", | |
" <td>New Zealand</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>1</td>\n", | |
" <td>Seddon Park, Hamilton</td>\n", | |
" <td>Away</td>\n", | |
" <td>18 March 2009</td>\n", | |
" <td>Won[52]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>42</th>\n", | |
" <td>43</td>\n", | |
" <td>100*</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>5</td>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>Sardar Patel Stadium, Ahmedabad</td>\n", | |
" <td>Home</td>\n", | |
" <td>16 November 2009</td>\n", | |
" <td>Drawn[53]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>43</th>\n", | |
" <td>44</td>\n", | |
" <td>105*</td>\n", | |
" <td>Bangladesh</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>Zohur Ahmed Chowdhury Stadium, Chittagong</td>\n", | |
" <td>Away</td>\n", | |
" <td>17 January 2010</td>\n", | |
" <td>Won[54]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>44</th>\n", | |
" <td>45</td>\n", | |
" <td>143</td>\n", | |
" <td>Bangladesh</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Sher-e-Bangla National Stadium, Mirpur</td>\n", | |
" <td>Away</td>\n", | |
" <td>24 January 2010</td>\n", | |
" <td>Won[55]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>45</th>\n", | |
" <td>46</td>\n", | |
" <td>100</td>\n", | |
" <td>South Africa</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>Vidarbha Cricket Association Stadium, Nagpur</td>\n", | |
" <td>Home</td>\n", | |
" <td>6 February 2010</td>\n", | |
" <td>Lost[56]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>46</th>\n", | |
" <td>47</td>\n", | |
" <td>106</td>\n", | |
" <td>South Africa</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Eden Gardens, Kolkata</td>\n", | |
" <td>Home</td>\n", | |
" <td>14 February 2010</td>\n", | |
" <td>Won[57]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>47</th>\n", | |
" <td>48</td>\n", | |
" <td>203</td>\n", | |
" <td>Sri Lanka</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>Sinhalese Sports Club Ground, Colombo</td>\n", | |
" <td>Away</td>\n", | |
" <td>26 July 2010</td>\n", | |
" <td>Drawn[58]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>48</th>\n", | |
" <td>49</td>\n", | |
" <td>214</td>\n", | |
" <td>Australia</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>M. Chinnaswamy Stadium, Bangalore</td>\n", | |
" <td>Home</td>\n", | |
" <td>9 October 2010</td>\n", | |
" <td>Won[59]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>49</th>\n", | |
" <td>50</td>\n", | |
" <td>111*</td>\n", | |
" <td>South Africa</td>\n", | |
" <td>5</td>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>SuperSport Park, Centurion</td>\n", | |
" <td>Away</td>\n", | |
" <td>16 December 2010</td>\n", | |
" <td>Lost[60]</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>50</th>\n", | |
" <td>51</td>\n", | |
" <td>146</td>\n", | |
" <td>South Africa</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>3</td>\n", | |
" <td>Newlands Cricket Ground, Cape Town</td>\n", | |
" <td>Away</td>\n", | |
" <td>2 January 2011</td>\n", | |
" <td>Drawn[61]</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" No. Score Against Pos. Inn. Test \\\n", | |
"0 1 119* England 6 4 2 \n", | |
"1 2 148* Australia 6 2 3 \n", | |
"2 3 114 Australia 4 2 5 \n", | |
"3 4 111 South Africa 4 2 2 \n", | |
"4 5 165 England 4 1 2 \n", | |
"5 6 104* Sri Lanka 4 3 2 \n", | |
"6 7 142 Sri Lanka 4 1 1 \n", | |
"7 8 179 West Indies 4 1 2 \n", | |
"8 9 122 England 4 3 1 \n", | |
"9 10 177 England 4 1 3 \n", | |
"10 11 169 South Africa 5 2 2 \n", | |
"11 12 143 Sri Lanka 4 1 1 \n", | |
"12 13 139 Sri Lanka 4 2 2 \n", | |
"13 14 148 Sri Lanka 5 1 3 \n", | |
"14 15 155* Australia 4 3 1 \n", | |
"15 16 177 Australia 4 1 3 \n", | |
"16 17 113 New Zealand 5 3 2 \n", | |
"17 18 136 Pakistan 4 4 1 \n", | |
"18 19 124* Sri Lanka 4 3 2 \n", | |
"19 20 126* New Zealand 4 3 1 \n", | |
"20 21 217 New Zealand 4 1 3 \n", | |
"21 22 116 Australia 4 2 2 \n", | |
"22 23 122 Zimbabwe 4 2 1 \n", | |
"23 24 201* Zimbabwe 4 1 2 \n", | |
"24 25 126 Australia 4 2 3 \n", | |
"25 26 155 South Africa 4 1 1 \n", | |
"26 27 103 England 4 2 2 \n", | |
"27 28 176 Zimbabwe 4 2 1 \n", | |
"28 29 117 West Indies 4 1 2 \n", | |
"29 30 193 England 4 1 3 \n", | |
"30 31 176 West Indies 4 3 3 \n", | |
"31 32 241* Australia 4 1 4 \n", | |
"32 33 194* Pakistan 4 1 1 \n", | |
"33 34 248* Bangladesh 4 2 1 \n", | |
"34 35 109 Sri Lanka 4 1 2 \n", | |
"35 36 101 Bangladesh 4 1 1 \n", | |
"36 37 122* Bangladesh 4 1 2 \n", | |
"37 38 154* Australia 4 2 2 \n", | |
"38 39 153 Australia 4 1 4 \n", | |
"39 40 109 Australia 4 1 4 \n", | |
"40 41 103* England 4 4 1 \n", | |
"41 42 160 New Zealand 4 2 1 \n", | |
"42 43 100* Sri Lanka 5 3 1 \n", | |
"43 44 105* Bangladesh 4 1 1 \n", | |
"44 45 143 Bangladesh 4 2 2 \n", | |
"45 46 100 South Africa 4 3 1 \n", | |
"46 47 106 South Africa 4 2 2 \n", | |
"47 48 203 Sri Lanka 4 2 2 \n", | |
"48 49 214 Australia 4 2 2 \n", | |
"49 50 111* South Africa 5 3 1 \n", | |
"50 51 146 South Africa 4 2 3 \n", | |
"\n", | |
" Venue H/A Date \\\n", | |
"0 Old Trafford, Manchester Away 9 August 1990 \n", | |
"1 Sydney Cricket Ground, Sydney Away 2 January 1992 \n", | |
"2 WACA Ground, Perth Away 1 February 1992 \n", | |
"3 Wanderers Stadium, Johannesburg Away 26 November 1992 \n", | |
"4 M. A. Chidambaram Stadium, Chennai Home 11 February 1993 \n", | |
"5 Sinhalese Sports Club Ground, Colombo Away 27 July 1993 \n", | |
"6 K. D. Singh Babu Stadium, Lucknow Home 18 January 1994 \n", | |
"7 Vidarbha Cricket Association Ground, Nagpur Home 1 December 1994 \n", | |
"8 Edgbaston, Birmingham Away 6 June 1996 \n", | |
"9 Trent Bridge, Nottingham Away 4 July 1996 \n", | |
"10 Newlands Cricket Ground, Cape Town Away 2 January 1997 \n", | |
"11 R. Premadasa Stadium, Colombo Away 2 August 1997 \n", | |
"12 Sinhalese Sports Club Ground, Colombo Away 9 August 1997 \n", | |
"13 Wankhede Stadium, Mumbai Home 3 December 1997 \n", | |
"14 M. A. Chidambaram Stadium, Chennai Home 6 March 1998 \n", | |
"15 M. Chinnaswamy Stadium, Bangalore Home 25 March 1998 \n", | |
"16 Basin Reserve, Wellington Away 26 December 1998 \n", | |
"17 M. A. Chidambaram Stadium, Chennai Home 28 January 1999 \n", | |
"18 Sinhalese Sports Club Ground, Colombo Away 24 February 1999 \n", | |
"19 Punjab Cricket Association Stadium, Mohali Home 10 October 1999 \n", | |
"20 Sardar Patel Stadium, Motera, Ahmedabad Home 29 October 1999 \n", | |
"21 Melbourne Cricket Ground, Melbourne Away 26 December 1999 \n", | |
"22 Feroz Shah Kotla, New Delhi Home 18 November 2000 \n", | |
"23 Vidarbha Cricket Association Ground, Nagpur Home 25 November 2000 \n", | |
"24 M. A. Chidambaram Stadium, Chennai Home 18 March 2001 \n", | |
"25 Goodyear Park, Bloemfontein Away 3 November 2001 \n", | |
"26 Sardar Patel Stadium, Ahmedabad Home 11 December 2001 \n", | |
"27 Vidarbha Cricket Association Ground, Nagpur Home 21 February 2002 \n", | |
"28 Queen's Park Oval, Port of Spain Away 19 April 2002 \n", | |
"29 Headingley, Leeds Away 22 August 2002 \n", | |
"30 Eden Gardens, Kolkata Home 30 October 2002 \n", | |
"31 Sydney Cricket Ground, Sydney Away 2 January 2004 \n", | |
"32 Multan Cricket Stadium, Multan Away 28 March 2004 \n", | |
"33 Bangabandhu National Stadium, Dhaka Away 10 December 2004 \n", | |
"34 Feroz Shah Kotla, New Delhi Home 10 December 2005 \n", | |
"35 Bir Shrestha Shahid Ruhul Amin Stadium, Chitta... Away 18 May 2007 \n", | |
"36 Sher-e-Bangla National Stadium, Mirpur Away 25 May 2007 \n", | |
"37 Sydney Cricket Ground, Sydney Away 2 January 2008 \n", | |
"38 Adelaide Oval, Adelaide Away 24 January 2008 \n", | |
"39 Vidarbha Cricket Association Stadium, Nagpur Home 6 November 2008 \n", | |
"40 M. A. Chidambaram Stadium, Chennai Home 11 December 2008 \n", | |
"41 Seddon Park, Hamilton Away 18 March 2009 \n", | |
"42 Sardar Patel Stadium, Ahmedabad Home 16 November 2009 \n", | |
"43 Zohur Ahmed Chowdhury Stadium, Chittagong Away 17 January 2010 \n", | |
"44 Sher-e-Bangla National Stadium, Mirpur Away 24 January 2010 \n", | |
"45 Vidarbha Cricket Association Stadium, Nagpur Home 6 February 2010 \n", | |
"46 Eden Gardens, Kolkata Home 14 February 2010 \n", | |
"47 Sinhalese Sports Club Ground, Colombo Away 26 July 2010 \n", | |
"48 M. Chinnaswamy Stadium, Bangalore Home 9 October 2010 \n", | |
"49 SuperSport Park, Centurion Away 16 December 2010 \n", | |
"50 Newlands Cricket Ground, Cape Town Away 2 January 2011 \n", | |
"\n", | |
" Result \n", | |
"0 Drawn[11] \n", | |
"1 Drawn[12] \n", | |
"2 Lost[13] \n", | |
"3 Drawn[14] \n", | |
"4 Won[15] \n", | |
"5 Won[16] \n", | |
"6 Won[17] \n", | |
"7 Drawn[18] \n", | |
"8 Lost[19] \n", | |
"9 Drawn[20] \n", | |
"10 Lost[21] \n", | |
"11 Drawn[22] \n", | |
"12 Drawn[23] \n", | |
"13 Drawn[24] \n", | |
"14 Won[25] \n", | |
"15 Lost[26] \n", | |
"16 Lost[27] \n", | |
"17 Lost[28] \n", | |
"18 Drawn[29] \n", | |
"19 Drawn[30] \n", | |
"20 Drawn[31] \n", | |
"21 Lost[32] \n", | |
"22 Won[33] \n", | |
"23 Drawn[34] \n", | |
"24 Won[35] \n", | |
"25 Lost[36] \n", | |
"26 Drawn[37] \n", | |
"27 Won[38] \n", | |
"28 Won[39] \n", | |
"29 Won[40] \n", | |
"30 Drawn[41] \n", | |
"31 Drawn[42] \n", | |
"32 Won[43] \n", | |
"33 Won[44] \n", | |
"34 Won[45] \n", | |
"35 Drawn[46] \n", | |
"36 Won[47] \n", | |
"37 Lost[48] \n", | |
"38 Drawn[49] \n", | |
"39 Won[50] \n", | |
"40 Won[51] \n", | |
"41 Won[52] \n", | |
"42 Drawn[53] \n", | |
"43 Won[54] \n", | |
"44 Won[55] \n", | |
"45 Lost[56] \n", | |
"46 Won[57] \n", | |
"47 Drawn[58] \n", | |
"48 Won[59] \n", | |
"49 Lost[60] \n", | |
"50 Drawn[61] " | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dfs[1]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"Australia 11\n", | |
"Sri Lanka 9\n", | |
"England 7\n", | |
"South Africa 7\n", | |
"Bangladesh 5\n", | |
"New Zealand 4\n", | |
"Zimbabwe 3\n", | |
"West Indies 3\n", | |
"Pakistan 2\n", | |
"Name: Against, dtype: int64" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dfs[1]['Against'].value_counts()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"scrolled": false | |
}, | |
"outputs": [], | |
"source": [ | |
"dfs[2].to_csv(\"odi_centuries.csv\")" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "pyenv37", | |
"language": "python", | |
"name": "pyenv37" | |
}, | |
"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.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment