Last active
October 1, 2017 17:32
-
-
Save koolhead17/8aca5ba19132041327a32640be7eaa0e to your computer and use it in GitHub Desktop.
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": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"### Blog: \n", | |
"http://atuljha.com/blog/2017/10/01/playing-with-python-pandas/" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"### Import pandas library and call it as pd.\n", | |
"import pandas as pd" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>State/ UTs</th>\n", | |
" <th>1951</th>\n", | |
" <th>1961</th>\n", | |
" <th>1971</th>\n", | |
" <th>1981</th>\n", | |
" <th>1991</th>\n", | |
" <th>2001</th>\n", | |
" <th>2011</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>Andaman and Nicobar Islands</td>\n", | |
" <td>30.30</td>\n", | |
" <td>40.07</td>\n", | |
" <td>51.15</td>\n", | |
" <td>63.19</td>\n", | |
" <td>73.02</td>\n", | |
" <td>81.30</td>\n", | |
" <td>86.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>Andhra Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>21.19</td>\n", | |
" <td>24.57</td>\n", | |
" <td>35.66</td>\n", | |
" <td>44.08</td>\n", | |
" <td>60.47</td>\n", | |
" <td>67.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>Arunachal Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>7.13</td>\n", | |
" <td>11.29</td>\n", | |
" <td>25.55</td>\n", | |
" <td>41.59</td>\n", | |
" <td>54.34</td>\n", | |
" <td>65.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Assam</td>\n", | |
" <td>18.53</td>\n", | |
" <td>32.95</td>\n", | |
" <td>33.94</td>\n", | |
" <td>NaN</td>\n", | |
" <td>52.89</td>\n", | |
" <td>63.25</td>\n", | |
" <td>72.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Bihar</td>\n", | |
" <td>13.49</td>\n", | |
" <td>21.95</td>\n", | |
" <td>23.17</td>\n", | |
" <td>32.32</td>\n", | |
" <td>37.49</td>\n", | |
" <td>47.00</td>\n", | |
" <td>61.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>Chandigarh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>70.43</td>\n", | |
" <td>74.80</td>\n", | |
" <td>77.81</td>\n", | |
" <td>81.94</td>\n", | |
" <td>86.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>Chhattisgarh</td>\n", | |
" <td>9.41</td>\n", | |
" <td>18.14</td>\n", | |
" <td>24.08</td>\n", | |
" <td>32.63</td>\n", | |
" <td>42.91</td>\n", | |
" <td>64.66</td>\n", | |
" <td>70.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>Dadra and Nagar Haveli</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>18.13</td>\n", | |
" <td>32.90</td>\n", | |
" <td>40.71</td>\n", | |
" <td>57.63</td>\n", | |
" <td>76.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>Daman and Diu</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>71.20</td>\n", | |
" <td>78.18</td>\n", | |
" <td>87.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>Delhi</td>\n", | |
" <td>NaN</td>\n", | |
" <td>61.95</td>\n", | |
" <td>65.08</td>\n", | |
" <td>71.94</td>\n", | |
" <td>75.29</td>\n", | |
" <td>81.67</td>\n", | |
" <td>86.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>Goa</td>\n", | |
" <td>23.48</td>\n", | |
" <td>35.41</td>\n", | |
" <td>51.96</td>\n", | |
" <td>65.71</td>\n", | |
" <td>75.51</td>\n", | |
" <td>82.01</td>\n", | |
" <td>88.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>Gujarat</td>\n", | |
" <td>21.82</td>\n", | |
" <td>31.47</td>\n", | |
" <td>36.95</td>\n", | |
" <td>44.92</td>\n", | |
" <td>61.29</td>\n", | |
" <td>69.14</td>\n", | |
" <td>78.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>12</th>\n", | |
" <td>Haryana</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>25.71</td>\n", | |
" <td>37.13</td>\n", | |
" <td>55.85</td>\n", | |
" <td>67.91</td>\n", | |
" <td>75.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>13</th>\n", | |
" <td>Himachal Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>63.86</td>\n", | |
" <td>76.48</td>\n", | |
" <td>82.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>14</th>\n", | |
" <td>Jammu and Kashmir</td>\n", | |
" <td>NaN</td>\n", | |
" <td>12.95</td>\n", | |
" <td>21.71</td>\n", | |
" <td>30.64</td>\n", | |
" <td>NaN</td>\n", | |
" <td>55.52</td>\n", | |
" <td>67.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>Jharkhand</td>\n", | |
" <td>12.93</td>\n", | |
" <td>21.14</td>\n", | |
" <td>23.87</td>\n", | |
" <td>35.03</td>\n", | |
" <td>41.39</td>\n", | |
" <td>53.56</td>\n", | |
" <td>66.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>16</th>\n", | |
" <td>Karnataka</td>\n", | |
" <td>NaN</td>\n", | |
" <td>29.80</td>\n", | |
" <td>36.83</td>\n", | |
" <td>46.21</td>\n", | |
" <td>56.04</td>\n", | |
" <td>66.64</td>\n", | |
" <td>75.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>17</th>\n", | |
" <td>Kerala</td>\n", | |
" <td>47.18</td>\n", | |
" <td>55.08</td>\n", | |
" <td>69.75</td>\n", | |
" <td>78.85</td>\n", | |
" <td>89.81</td>\n", | |
" <td>90.86</td>\n", | |
" <td>94.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>18</th>\n", | |
" <td>Lakshadweep</td>\n", | |
" <td>15.23</td>\n", | |
" <td>27.15</td>\n", | |
" <td>51.76</td>\n", | |
" <td>68.42</td>\n", | |
" <td>81.78</td>\n", | |
" <td>86.66</td>\n", | |
" <td>91.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>19</th>\n", | |
" <td>Madhya Pradesh</td>\n", | |
" <td>13.16</td>\n", | |
" <td>21.41</td>\n", | |
" <td>27.27</td>\n", | |
" <td>38.63</td>\n", | |
" <td>44.67</td>\n", | |
" <td>63.74</td>\n", | |
" <td>69.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>20</th>\n", | |
" <td>Maharashtra</td>\n", | |
" <td>27.91</td>\n", | |
" <td>35.08</td>\n", | |
" <td>45.77</td>\n", | |
" <td>57.24</td>\n", | |
" <td>64.87</td>\n", | |
" <td>76.88</td>\n", | |
" <td>82.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>21</th>\n", | |
" <td>Manipur</td>\n", | |
" <td>12.57</td>\n", | |
" <td>36.04</td>\n", | |
" <td>38.47</td>\n", | |
" <td>49.66</td>\n", | |
" <td>59.89</td>\n", | |
" <td>70.53</td>\n", | |
" <td>76.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>22</th>\n", | |
" <td>Meghalaya</td>\n", | |
" <td>NaN</td>\n", | |
" <td>26.92</td>\n", | |
" <td>29.49</td>\n", | |
" <td>42.05</td>\n", | |
" <td>49.10</td>\n", | |
" <td>62.56</td>\n", | |
" <td>74.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>23</th>\n", | |
" <td>Mizoram</td>\n", | |
" <td>31.14</td>\n", | |
" <td>44.01</td>\n", | |
" <td>53.80</td>\n", | |
" <td>59.88</td>\n", | |
" <td>82.26</td>\n", | |
" <td>88.80</td>\n", | |
" <td>91.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>24</th>\n", | |
" <td>Nagaland</td>\n", | |
" <td>10.52</td>\n", | |
" <td>21.95</td>\n", | |
" <td>33.78</td>\n", | |
" <td>50.28</td>\n", | |
" <td>61.65</td>\n", | |
" <td>66.59</td>\n", | |
" <td>79.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25</th>\n", | |
" <td>Odisha</td>\n", | |
" <td>15.80</td>\n", | |
" <td>21.66</td>\n", | |
" <td>26.18</td>\n", | |
" <td>33.62</td>\n", | |
" <td>49.09</td>\n", | |
" <td>63.08</td>\n", | |
" <td>72.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>26</th>\n", | |
" <td>Puducherry</td>\n", | |
" <td>NaN</td>\n", | |
" <td>43.65</td>\n", | |
" <td>53.38</td>\n", | |
" <td>65.14</td>\n", | |
" <td>74.74</td>\n", | |
" <td>81.24</td>\n", | |
" <td>85.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>27</th>\n", | |
" <td>Punjab</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>34.12</td>\n", | |
" <td>43.37</td>\n", | |
" <td>58.51</td>\n", | |
" <td>69.65</td>\n", | |
" <td>75.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>28</th>\n", | |
" <td>Rajasthan</td>\n", | |
" <td>8.50</td>\n", | |
" <td>18.12</td>\n", | |
" <td>22.57</td>\n", | |
" <td>30.11</td>\n", | |
" <td>38.55</td>\n", | |
" <td>60.41</td>\n", | |
" <td>66.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>29</th>\n", | |
" <td>Sikkim</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>17.74</td>\n", | |
" <td>34.05</td>\n", | |
" <td>56.94</td>\n", | |
" <td>68.81</td>\n", | |
" <td>81.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>30</th>\n", | |
" <td>Tamil Nadu</td>\n", | |
" <td>NaN</td>\n", | |
" <td>36.39</td>\n", | |
" <td>45.40</td>\n", | |
" <td>54.39</td>\n", | |
" <td>62.66</td>\n", | |
" <td>73.45</td>\n", | |
" <td>80.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31</th>\n", | |
" <td>Tripura</td>\n", | |
" <td>NaN</td>\n", | |
" <td>20.24</td>\n", | |
" <td>30.98</td>\n", | |
" <td>50.10</td>\n", | |
" <td>60.44</td>\n", | |
" <td>73.19</td>\n", | |
" <td>87.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>32</th>\n", | |
" <td>Uttar Pradesh</td>\n", | |
" <td>12.02</td>\n", | |
" <td>20.87</td>\n", | |
" <td>23.99</td>\n", | |
" <td>32.65</td>\n", | |
" <td>40.71</td>\n", | |
" <td>56.27</td>\n", | |
" <td>67.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>33</th>\n", | |
" <td>Uttarakhand</td>\n", | |
" <td>18.93</td>\n", | |
" <td>18.05</td>\n", | |
" <td>33.26</td>\n", | |
" <td>46.06</td>\n", | |
" <td>57.75</td>\n", | |
" <td>71.62</td>\n", | |
" <td>78.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>34</th>\n", | |
" <td>West Bengal</td>\n", | |
" <td>24.61</td>\n", | |
" <td>34.46</td>\n", | |
" <td>38.86</td>\n", | |
" <td>48.65</td>\n", | |
" <td>57.70</td>\n", | |
" <td>68.64</td>\n", | |
" <td>76.3</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" State/ UTs 1951 1961 1971 1981 1991 2001 \\\n", | |
"0 Andaman and Nicobar Islands 30.30 40.07 51.15 63.19 73.02 81.30 \n", | |
"1 Andhra Pradesh NaN 21.19 24.57 35.66 44.08 60.47 \n", | |
"2 Arunachal Pradesh NaN 7.13 11.29 25.55 41.59 54.34 \n", | |
"3 Assam 18.53 32.95 33.94 NaN 52.89 63.25 \n", | |
"4 Bihar 13.49 21.95 23.17 32.32 37.49 47.00 \n", | |
"5 Chandigarh NaN NaN 70.43 74.80 77.81 81.94 \n", | |
"6 Chhattisgarh 9.41 18.14 24.08 32.63 42.91 64.66 \n", | |
"7 Dadra and Nagar Haveli NaN NaN 18.13 32.90 40.71 57.63 \n", | |
"8 Daman and Diu NaN NaN NaN NaN 71.20 78.18 \n", | |
"9 Delhi NaN 61.95 65.08 71.94 75.29 81.67 \n", | |
"10 Goa 23.48 35.41 51.96 65.71 75.51 82.01 \n", | |
"11 Gujarat 21.82 31.47 36.95 44.92 61.29 69.14 \n", | |
"12 Haryana NaN NaN 25.71 37.13 55.85 67.91 \n", | |
"13 Himachal Pradesh NaN NaN NaN NaN 63.86 76.48 \n", | |
"14 Jammu and Kashmir NaN 12.95 21.71 30.64 NaN 55.52 \n", | |
"15 Jharkhand 12.93 21.14 23.87 35.03 41.39 53.56 \n", | |
"16 Karnataka NaN 29.80 36.83 46.21 56.04 66.64 \n", | |
"17 Kerala 47.18 55.08 69.75 78.85 89.81 90.86 \n", | |
"18 Lakshadweep 15.23 27.15 51.76 68.42 81.78 86.66 \n", | |
"19 Madhya Pradesh 13.16 21.41 27.27 38.63 44.67 63.74 \n", | |
"20 Maharashtra 27.91 35.08 45.77 57.24 64.87 76.88 \n", | |
"21 Manipur 12.57 36.04 38.47 49.66 59.89 70.53 \n", | |
"22 Meghalaya NaN 26.92 29.49 42.05 49.10 62.56 \n", | |
"23 Mizoram 31.14 44.01 53.80 59.88 82.26 88.80 \n", | |
"24 Nagaland 10.52 21.95 33.78 50.28 61.65 66.59 \n", | |
"25 Odisha 15.80 21.66 26.18 33.62 49.09 63.08 \n", | |
"26 Puducherry NaN 43.65 53.38 65.14 74.74 81.24 \n", | |
"27 Punjab NaN NaN 34.12 43.37 58.51 69.65 \n", | |
"28 Rajasthan 8.50 18.12 22.57 30.11 38.55 60.41 \n", | |
"29 Sikkim NaN NaN 17.74 34.05 56.94 68.81 \n", | |
"30 Tamil Nadu NaN 36.39 45.40 54.39 62.66 73.45 \n", | |
"31 Tripura NaN 20.24 30.98 50.10 60.44 73.19 \n", | |
"32 Uttar Pradesh 12.02 20.87 23.99 32.65 40.71 56.27 \n", | |
"33 Uttarakhand 18.93 18.05 33.26 46.06 57.75 71.62 \n", | |
"34 West Bengal 24.61 34.46 38.86 48.65 57.70 68.64 \n", | |
"\n", | |
" 2011 \n", | |
"0 86.6 \n", | |
"1 67.0 \n", | |
"2 65.4 \n", | |
"3 72.2 \n", | |
"4 61.8 \n", | |
"5 86.0 \n", | |
"6 70.3 \n", | |
"7 76.2 \n", | |
"8 87.1 \n", | |
"9 86.2 \n", | |
"10 88.7 \n", | |
"11 78.0 \n", | |
"12 75.6 \n", | |
"13 82.8 \n", | |
"14 67.2 \n", | |
"15 66.4 \n", | |
"16 75.4 \n", | |
"17 94.0 \n", | |
"18 91.8 \n", | |
"19 69.3 \n", | |
"20 82.3 \n", | |
"21 76.9 \n", | |
"22 74.4 \n", | |
"23 91.3 \n", | |
"24 79.6 \n", | |
"25 72.9 \n", | |
"26 85.8 \n", | |
"27 75.8 \n", | |
"28 66.1 \n", | |
"29 81.4 \n", | |
"30 80.1 \n", | |
"31 87.2 \n", | |
"32 67.7 \n", | |
"33 78.8 \n", | |
"34 76.3 " | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### Load the CSV file\n", | |
"pd.read_csv(\"litrate.csv\") " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"### save CSV file in dataframe \n", | |
"df = pd.read_csv(\"litrate.csv\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>State/ UTs</th>\n", | |
" <th>1951</th>\n", | |
" <th>1961</th>\n", | |
" <th>1971</th>\n", | |
" <th>1981</th>\n", | |
" <th>1991</th>\n", | |
" <th>2001</th>\n", | |
" <th>2011</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>Andaman and Nicobar Islands</td>\n", | |
" <td>30.30</td>\n", | |
" <td>40.07</td>\n", | |
" <td>51.15</td>\n", | |
" <td>63.19</td>\n", | |
" <td>73.02</td>\n", | |
" <td>81.30</td>\n", | |
" <td>86.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>Andhra Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>21.19</td>\n", | |
" <td>24.57</td>\n", | |
" <td>35.66</td>\n", | |
" <td>44.08</td>\n", | |
" <td>60.47</td>\n", | |
" <td>67.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>Arunachal Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>7.13</td>\n", | |
" <td>11.29</td>\n", | |
" <td>25.55</td>\n", | |
" <td>41.59</td>\n", | |
" <td>54.34</td>\n", | |
" <td>65.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Assam</td>\n", | |
" <td>18.53</td>\n", | |
" <td>32.95</td>\n", | |
" <td>33.94</td>\n", | |
" <td>NaN</td>\n", | |
" <td>52.89</td>\n", | |
" <td>63.25</td>\n", | |
" <td>72.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Bihar</td>\n", | |
" <td>13.49</td>\n", | |
" <td>21.95</td>\n", | |
" <td>23.17</td>\n", | |
" <td>32.32</td>\n", | |
" <td>37.49</td>\n", | |
" <td>47.00</td>\n", | |
" <td>61.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>Chandigarh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>70.43</td>\n", | |
" <td>74.80</td>\n", | |
" <td>77.81</td>\n", | |
" <td>81.94</td>\n", | |
" <td>86.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>Chhattisgarh</td>\n", | |
" <td>9.41</td>\n", | |
" <td>18.14</td>\n", | |
" <td>24.08</td>\n", | |
" <td>32.63</td>\n", | |
" <td>42.91</td>\n", | |
" <td>64.66</td>\n", | |
" <td>70.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>Dadra and Nagar Haveli</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>18.13</td>\n", | |
" <td>32.90</td>\n", | |
" <td>40.71</td>\n", | |
" <td>57.63</td>\n", | |
" <td>76.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>Daman and Diu</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>71.20</td>\n", | |
" <td>78.18</td>\n", | |
" <td>87.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>Delhi</td>\n", | |
" <td>NaN</td>\n", | |
" <td>61.95</td>\n", | |
" <td>65.08</td>\n", | |
" <td>71.94</td>\n", | |
" <td>75.29</td>\n", | |
" <td>81.67</td>\n", | |
" <td>86.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>Goa</td>\n", | |
" <td>23.48</td>\n", | |
" <td>35.41</td>\n", | |
" <td>51.96</td>\n", | |
" <td>65.71</td>\n", | |
" <td>75.51</td>\n", | |
" <td>82.01</td>\n", | |
" <td>88.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>Gujarat</td>\n", | |
" <td>21.82</td>\n", | |
" <td>31.47</td>\n", | |
" <td>36.95</td>\n", | |
" <td>44.92</td>\n", | |
" <td>61.29</td>\n", | |
" <td>69.14</td>\n", | |
" <td>78.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>12</th>\n", | |
" <td>Haryana</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>25.71</td>\n", | |
" <td>37.13</td>\n", | |
" <td>55.85</td>\n", | |
" <td>67.91</td>\n", | |
" <td>75.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>13</th>\n", | |
" <td>Himachal Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>63.86</td>\n", | |
" <td>76.48</td>\n", | |
" <td>82.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>14</th>\n", | |
" <td>Jammu and Kashmir</td>\n", | |
" <td>NaN</td>\n", | |
" <td>12.95</td>\n", | |
" <td>21.71</td>\n", | |
" <td>30.64</td>\n", | |
" <td>NaN</td>\n", | |
" <td>55.52</td>\n", | |
" <td>67.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>Jharkhand</td>\n", | |
" <td>12.93</td>\n", | |
" <td>21.14</td>\n", | |
" <td>23.87</td>\n", | |
" <td>35.03</td>\n", | |
" <td>41.39</td>\n", | |
" <td>53.56</td>\n", | |
" <td>66.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>16</th>\n", | |
" <td>Karnataka</td>\n", | |
" <td>NaN</td>\n", | |
" <td>29.80</td>\n", | |
" <td>36.83</td>\n", | |
" <td>46.21</td>\n", | |
" <td>56.04</td>\n", | |
" <td>66.64</td>\n", | |
" <td>75.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>17</th>\n", | |
" <td>Kerala</td>\n", | |
" <td>47.18</td>\n", | |
" <td>55.08</td>\n", | |
" <td>69.75</td>\n", | |
" <td>78.85</td>\n", | |
" <td>89.81</td>\n", | |
" <td>90.86</td>\n", | |
" <td>94.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>18</th>\n", | |
" <td>Lakshadweep</td>\n", | |
" <td>15.23</td>\n", | |
" <td>27.15</td>\n", | |
" <td>51.76</td>\n", | |
" <td>68.42</td>\n", | |
" <td>81.78</td>\n", | |
" <td>86.66</td>\n", | |
" <td>91.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>19</th>\n", | |
" <td>Madhya Pradesh</td>\n", | |
" <td>13.16</td>\n", | |
" <td>21.41</td>\n", | |
" <td>27.27</td>\n", | |
" <td>38.63</td>\n", | |
" <td>44.67</td>\n", | |
" <td>63.74</td>\n", | |
" <td>69.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>20</th>\n", | |
" <td>Maharashtra</td>\n", | |
" <td>27.91</td>\n", | |
" <td>35.08</td>\n", | |
" <td>45.77</td>\n", | |
" <td>57.24</td>\n", | |
" <td>64.87</td>\n", | |
" <td>76.88</td>\n", | |
" <td>82.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>21</th>\n", | |
" <td>Manipur</td>\n", | |
" <td>12.57</td>\n", | |
" <td>36.04</td>\n", | |
" <td>38.47</td>\n", | |
" <td>49.66</td>\n", | |
" <td>59.89</td>\n", | |
" <td>70.53</td>\n", | |
" <td>76.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>22</th>\n", | |
" <td>Meghalaya</td>\n", | |
" <td>NaN</td>\n", | |
" <td>26.92</td>\n", | |
" <td>29.49</td>\n", | |
" <td>42.05</td>\n", | |
" <td>49.10</td>\n", | |
" <td>62.56</td>\n", | |
" <td>74.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>23</th>\n", | |
" <td>Mizoram</td>\n", | |
" <td>31.14</td>\n", | |
" <td>44.01</td>\n", | |
" <td>53.80</td>\n", | |
" <td>59.88</td>\n", | |
" <td>82.26</td>\n", | |
" <td>88.80</td>\n", | |
" <td>91.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>24</th>\n", | |
" <td>Nagaland</td>\n", | |
" <td>10.52</td>\n", | |
" <td>21.95</td>\n", | |
" <td>33.78</td>\n", | |
" <td>50.28</td>\n", | |
" <td>61.65</td>\n", | |
" <td>66.59</td>\n", | |
" <td>79.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25</th>\n", | |
" <td>Odisha</td>\n", | |
" <td>15.80</td>\n", | |
" <td>21.66</td>\n", | |
" <td>26.18</td>\n", | |
" <td>33.62</td>\n", | |
" <td>49.09</td>\n", | |
" <td>63.08</td>\n", | |
" <td>72.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>26</th>\n", | |
" <td>Puducherry</td>\n", | |
" <td>NaN</td>\n", | |
" <td>43.65</td>\n", | |
" <td>53.38</td>\n", | |
" <td>65.14</td>\n", | |
" <td>74.74</td>\n", | |
" <td>81.24</td>\n", | |
" <td>85.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>27</th>\n", | |
" <td>Punjab</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>34.12</td>\n", | |
" <td>43.37</td>\n", | |
" <td>58.51</td>\n", | |
" <td>69.65</td>\n", | |
" <td>75.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>28</th>\n", | |
" <td>Rajasthan</td>\n", | |
" <td>8.50</td>\n", | |
" <td>18.12</td>\n", | |
" <td>22.57</td>\n", | |
" <td>30.11</td>\n", | |
" <td>38.55</td>\n", | |
" <td>60.41</td>\n", | |
" <td>66.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>29</th>\n", | |
" <td>Sikkim</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>17.74</td>\n", | |
" <td>34.05</td>\n", | |
" <td>56.94</td>\n", | |
" <td>68.81</td>\n", | |
" <td>81.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>30</th>\n", | |
" <td>Tamil Nadu</td>\n", | |
" <td>NaN</td>\n", | |
" <td>36.39</td>\n", | |
" <td>45.40</td>\n", | |
" <td>54.39</td>\n", | |
" <td>62.66</td>\n", | |
" <td>73.45</td>\n", | |
" <td>80.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31</th>\n", | |
" <td>Tripura</td>\n", | |
" <td>NaN</td>\n", | |
" <td>20.24</td>\n", | |
" <td>30.98</td>\n", | |
" <td>50.10</td>\n", | |
" <td>60.44</td>\n", | |
" <td>73.19</td>\n", | |
" <td>87.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>32</th>\n", | |
" <td>Uttar Pradesh</td>\n", | |
" <td>12.02</td>\n", | |
" <td>20.87</td>\n", | |
" <td>23.99</td>\n", | |
" <td>32.65</td>\n", | |
" <td>40.71</td>\n", | |
" <td>56.27</td>\n", | |
" <td>67.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>33</th>\n", | |
" <td>Uttarakhand</td>\n", | |
" <td>18.93</td>\n", | |
" <td>18.05</td>\n", | |
" <td>33.26</td>\n", | |
" <td>46.06</td>\n", | |
" <td>57.75</td>\n", | |
" <td>71.62</td>\n", | |
" <td>78.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>34</th>\n", | |
" <td>West Bengal</td>\n", | |
" <td>24.61</td>\n", | |
" <td>34.46</td>\n", | |
" <td>38.86</td>\n", | |
" <td>48.65</td>\n", | |
" <td>57.70</td>\n", | |
" <td>68.64</td>\n", | |
" <td>76.3</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" State/ UTs 1951 1961 1971 1981 1991 2001 \\\n", | |
"0 Andaman and Nicobar Islands 30.30 40.07 51.15 63.19 73.02 81.30 \n", | |
"1 Andhra Pradesh NaN 21.19 24.57 35.66 44.08 60.47 \n", | |
"2 Arunachal Pradesh NaN 7.13 11.29 25.55 41.59 54.34 \n", | |
"3 Assam 18.53 32.95 33.94 NaN 52.89 63.25 \n", | |
"4 Bihar 13.49 21.95 23.17 32.32 37.49 47.00 \n", | |
"5 Chandigarh NaN NaN 70.43 74.80 77.81 81.94 \n", | |
"6 Chhattisgarh 9.41 18.14 24.08 32.63 42.91 64.66 \n", | |
"7 Dadra and Nagar Haveli NaN NaN 18.13 32.90 40.71 57.63 \n", | |
"8 Daman and Diu NaN NaN NaN NaN 71.20 78.18 \n", | |
"9 Delhi NaN 61.95 65.08 71.94 75.29 81.67 \n", | |
"10 Goa 23.48 35.41 51.96 65.71 75.51 82.01 \n", | |
"11 Gujarat 21.82 31.47 36.95 44.92 61.29 69.14 \n", | |
"12 Haryana NaN NaN 25.71 37.13 55.85 67.91 \n", | |
"13 Himachal Pradesh NaN NaN NaN NaN 63.86 76.48 \n", | |
"14 Jammu and Kashmir NaN 12.95 21.71 30.64 NaN 55.52 \n", | |
"15 Jharkhand 12.93 21.14 23.87 35.03 41.39 53.56 \n", | |
"16 Karnataka NaN 29.80 36.83 46.21 56.04 66.64 \n", | |
"17 Kerala 47.18 55.08 69.75 78.85 89.81 90.86 \n", | |
"18 Lakshadweep 15.23 27.15 51.76 68.42 81.78 86.66 \n", | |
"19 Madhya Pradesh 13.16 21.41 27.27 38.63 44.67 63.74 \n", | |
"20 Maharashtra 27.91 35.08 45.77 57.24 64.87 76.88 \n", | |
"21 Manipur 12.57 36.04 38.47 49.66 59.89 70.53 \n", | |
"22 Meghalaya NaN 26.92 29.49 42.05 49.10 62.56 \n", | |
"23 Mizoram 31.14 44.01 53.80 59.88 82.26 88.80 \n", | |
"24 Nagaland 10.52 21.95 33.78 50.28 61.65 66.59 \n", | |
"25 Odisha 15.80 21.66 26.18 33.62 49.09 63.08 \n", | |
"26 Puducherry NaN 43.65 53.38 65.14 74.74 81.24 \n", | |
"27 Punjab NaN NaN 34.12 43.37 58.51 69.65 \n", | |
"28 Rajasthan 8.50 18.12 22.57 30.11 38.55 60.41 \n", | |
"29 Sikkim NaN NaN 17.74 34.05 56.94 68.81 \n", | |
"30 Tamil Nadu NaN 36.39 45.40 54.39 62.66 73.45 \n", | |
"31 Tripura NaN 20.24 30.98 50.10 60.44 73.19 \n", | |
"32 Uttar Pradesh 12.02 20.87 23.99 32.65 40.71 56.27 \n", | |
"33 Uttarakhand 18.93 18.05 33.26 46.06 57.75 71.62 \n", | |
"34 West Bengal 24.61 34.46 38.86 48.65 57.70 68.64 \n", | |
"\n", | |
" 2011 \n", | |
"0 86.6 \n", | |
"1 67.0 \n", | |
"2 65.4 \n", | |
"3 72.2 \n", | |
"4 61.8 \n", | |
"5 86.0 \n", | |
"6 70.3 \n", | |
"7 76.2 \n", | |
"8 87.1 \n", | |
"9 86.2 \n", | |
"10 88.7 \n", | |
"11 78.0 \n", | |
"12 75.6 \n", | |
"13 82.8 \n", | |
"14 67.2 \n", | |
"15 66.4 \n", | |
"16 75.4 \n", | |
"17 94.0 \n", | |
"18 91.8 \n", | |
"19 69.3 \n", | |
"20 82.3 \n", | |
"21 76.9 \n", | |
"22 74.4 \n", | |
"23 91.3 \n", | |
"24 79.6 \n", | |
"25 72.9 \n", | |
"26 85.8 \n", | |
"27 75.8 \n", | |
"28 66.1 \n", | |
"29 81.4 \n", | |
"30 80.1 \n", | |
"31 87.2 \n", | |
"32 67.7 \n", | |
"33 78.8 \n", | |
"34 76.3 " | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>State/ UTs</th>\n", | |
" <th>1951</th>\n", | |
" <th>1961</th>\n", | |
" <th>1971</th>\n", | |
" <th>1981</th>\n", | |
" <th>1991</th>\n", | |
" <th>2001</th>\n", | |
" <th>2011</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>Andaman and Nicobar Islands</td>\n", | |
" <td>30.30</td>\n", | |
" <td>40.07</td>\n", | |
" <td>51.15</td>\n", | |
" <td>63.19</td>\n", | |
" <td>73.02</td>\n", | |
" <td>81.30</td>\n", | |
" <td>86.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>Andhra Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>21.19</td>\n", | |
" <td>24.57</td>\n", | |
" <td>35.66</td>\n", | |
" <td>44.08</td>\n", | |
" <td>60.47</td>\n", | |
" <td>67.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>Arunachal Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>7.13</td>\n", | |
" <td>11.29</td>\n", | |
" <td>25.55</td>\n", | |
" <td>41.59</td>\n", | |
" <td>54.34</td>\n", | |
" <td>65.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Assam</td>\n", | |
" <td>18.53</td>\n", | |
" <td>32.95</td>\n", | |
" <td>33.94</td>\n", | |
" <td>NaN</td>\n", | |
" <td>52.89</td>\n", | |
" <td>63.25</td>\n", | |
" <td>72.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Bihar</td>\n", | |
" <td>13.49</td>\n", | |
" <td>21.95</td>\n", | |
" <td>23.17</td>\n", | |
" <td>32.32</td>\n", | |
" <td>37.49</td>\n", | |
" <td>47.00</td>\n", | |
" <td>61.8</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" State/ UTs 1951 1961 1971 1981 1991 2001 2011\n", | |
"0 Andaman and Nicobar Islands 30.30 40.07 51.15 63.19 73.02 81.30 86.6\n", | |
"1 Andhra Pradesh NaN 21.19 24.57 35.66 44.08 60.47 67.0\n", | |
"2 Arunachal Pradesh NaN 7.13 11.29 25.55 41.59 54.34 65.4\n", | |
"3 Assam 18.53 32.95 33.94 NaN 52.89 63.25 72.2\n", | |
"4 Bihar 13.49 21.95 23.17 32.32 37.49 47.00 61.8" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### List top 5 rows of the Dataset\n", | |
"df.head()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"pandas.core.frame.DataFrame" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### Identify the type of Dataframe\n", | |
"type(df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(35, 8)" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### Investigate the number of rows and coloumns of the Dataframe\n", | |
"df.shape" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"Index([u'State/ UTs', u'1951', u'1961', u'1971', u'1981', u'1991', u'2001',\n", | |
" u'2011'],\n", | |
" dtype='object')" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### Titles of the coloumns\n", | |
"df.columns" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"State/ UTs object\n", | |
"1951 float64\n", | |
"1961 float64\n", | |
"1971 float64\n", | |
"1981 float64\n", | |
"1991 float64\n", | |
"2001 float64\n", | |
"2011 float64\n", | |
"dtype: object" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### List datatypes of the Dataframe\n", | |
"df.dtypes" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0 73.02\n", | |
"1 44.08\n", | |
"2 41.59\n", | |
"3 52.89\n", | |
"4 37.49\n", | |
"5 77.81\n", | |
"6 42.91\n", | |
"7 40.71\n", | |
"8 71.20\n", | |
"9 75.29\n", | |
"10 75.51\n", | |
"11 61.29\n", | |
"12 55.85\n", | |
"13 63.86\n", | |
"14 NaN\n", | |
"15 41.39\n", | |
"16 56.04\n", | |
"17 89.81\n", | |
"18 81.78\n", | |
"19 44.67\n", | |
"20 64.87\n", | |
"21 59.89\n", | |
"22 49.10\n", | |
"23 82.26\n", | |
"24 61.65\n", | |
"25 49.09\n", | |
"26 74.74\n", | |
"27 58.51\n", | |
"28 38.55\n", | |
"29 56.94\n", | |
"30 62.66\n", | |
"31 60.44\n", | |
"32 40.71\n", | |
"33 57.75\n", | |
"34 57.70\n", | |
"Name: 1991, dtype: float64" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### Content of coloumn name '1991'\n", | |
"df['1991']" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"### Rename columns name from 'State/ UTs' to 'State'\n", | |
"df.rename(columns={'State/ UTs': 'State'}, inplace=True)\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>State</th>\n", | |
" <th>1951</th>\n", | |
" <th>1961</th>\n", | |
" <th>1971</th>\n", | |
" <th>1981</th>\n", | |
" <th>1991</th>\n", | |
" <th>2001</th>\n", | |
" <th>2011</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>Andaman and Nicobar Islands</td>\n", | |
" <td>30.30</td>\n", | |
" <td>40.07</td>\n", | |
" <td>51.15</td>\n", | |
" <td>63.19</td>\n", | |
" <td>73.02</td>\n", | |
" <td>81.30</td>\n", | |
" <td>86.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>Andhra Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>21.19</td>\n", | |
" <td>24.57</td>\n", | |
" <td>35.66</td>\n", | |
" <td>44.08</td>\n", | |
" <td>60.47</td>\n", | |
" <td>67.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>Arunachal Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>7.13</td>\n", | |
" <td>11.29</td>\n", | |
" <td>25.55</td>\n", | |
" <td>41.59</td>\n", | |
" <td>54.34</td>\n", | |
" <td>65.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Assam</td>\n", | |
" <td>18.53</td>\n", | |
" <td>32.95</td>\n", | |
" <td>33.94</td>\n", | |
" <td>NaN</td>\n", | |
" <td>52.89</td>\n", | |
" <td>63.25</td>\n", | |
" <td>72.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Bihar</td>\n", | |
" <td>13.49</td>\n", | |
" <td>21.95</td>\n", | |
" <td>23.17</td>\n", | |
" <td>32.32</td>\n", | |
" <td>37.49</td>\n", | |
" <td>47.00</td>\n", | |
" <td>61.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>Chandigarh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>70.43</td>\n", | |
" <td>74.80</td>\n", | |
" <td>77.81</td>\n", | |
" <td>81.94</td>\n", | |
" <td>86.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>Chhattisgarh</td>\n", | |
" <td>9.41</td>\n", | |
" <td>18.14</td>\n", | |
" <td>24.08</td>\n", | |
" <td>32.63</td>\n", | |
" <td>42.91</td>\n", | |
" <td>64.66</td>\n", | |
" <td>70.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>Dadra and Nagar Haveli</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>18.13</td>\n", | |
" <td>32.90</td>\n", | |
" <td>40.71</td>\n", | |
" <td>57.63</td>\n", | |
" <td>76.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>Daman and Diu</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>71.20</td>\n", | |
" <td>78.18</td>\n", | |
" <td>87.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>Delhi</td>\n", | |
" <td>NaN</td>\n", | |
" <td>61.95</td>\n", | |
" <td>65.08</td>\n", | |
" <td>71.94</td>\n", | |
" <td>75.29</td>\n", | |
" <td>81.67</td>\n", | |
" <td>86.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>Goa</td>\n", | |
" <td>23.48</td>\n", | |
" <td>35.41</td>\n", | |
" <td>51.96</td>\n", | |
" <td>65.71</td>\n", | |
" <td>75.51</td>\n", | |
" <td>82.01</td>\n", | |
" <td>88.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>Gujarat</td>\n", | |
" <td>21.82</td>\n", | |
" <td>31.47</td>\n", | |
" <td>36.95</td>\n", | |
" <td>44.92</td>\n", | |
" <td>61.29</td>\n", | |
" <td>69.14</td>\n", | |
" <td>78.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>12</th>\n", | |
" <td>Haryana</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>25.71</td>\n", | |
" <td>37.13</td>\n", | |
" <td>55.85</td>\n", | |
" <td>67.91</td>\n", | |
" <td>75.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>13</th>\n", | |
" <td>Himachal Pradesh</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>63.86</td>\n", | |
" <td>76.48</td>\n", | |
" <td>82.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>14</th>\n", | |
" <td>Jammu and Kashmir</td>\n", | |
" <td>NaN</td>\n", | |
" <td>12.95</td>\n", | |
" <td>21.71</td>\n", | |
" <td>30.64</td>\n", | |
" <td>NaN</td>\n", | |
" <td>55.52</td>\n", | |
" <td>67.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>Jharkhand</td>\n", | |
" <td>12.93</td>\n", | |
" <td>21.14</td>\n", | |
" <td>23.87</td>\n", | |
" <td>35.03</td>\n", | |
" <td>41.39</td>\n", | |
" <td>53.56</td>\n", | |
" <td>66.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>16</th>\n", | |
" <td>Karnataka</td>\n", | |
" <td>NaN</td>\n", | |
" <td>29.80</td>\n", | |
" <td>36.83</td>\n", | |
" <td>46.21</td>\n", | |
" <td>56.04</td>\n", | |
" <td>66.64</td>\n", | |
" <td>75.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>17</th>\n", | |
" <td>Kerala</td>\n", | |
" <td>47.18</td>\n", | |
" <td>55.08</td>\n", | |
" <td>69.75</td>\n", | |
" <td>78.85</td>\n", | |
" <td>89.81</td>\n", | |
" <td>90.86</td>\n", | |
" <td>94.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>18</th>\n", | |
" <td>Lakshadweep</td>\n", | |
" <td>15.23</td>\n", | |
" <td>27.15</td>\n", | |
" <td>51.76</td>\n", | |
" <td>68.42</td>\n", | |
" <td>81.78</td>\n", | |
" <td>86.66</td>\n", | |
" <td>91.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>19</th>\n", | |
" <td>Madhya Pradesh</td>\n", | |
" <td>13.16</td>\n", | |
" <td>21.41</td>\n", | |
" <td>27.27</td>\n", | |
" <td>38.63</td>\n", | |
" <td>44.67</td>\n", | |
" <td>63.74</td>\n", | |
" <td>69.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>20</th>\n", | |
" <td>Maharashtra</td>\n", | |
" <td>27.91</td>\n", | |
" <td>35.08</td>\n", | |
" <td>45.77</td>\n", | |
" <td>57.24</td>\n", | |
" <td>64.87</td>\n", | |
" <td>76.88</td>\n", | |
" <td>82.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>21</th>\n", | |
" <td>Manipur</td>\n", | |
" <td>12.57</td>\n", | |
" <td>36.04</td>\n", | |
" <td>38.47</td>\n", | |
" <td>49.66</td>\n", | |
" <td>59.89</td>\n", | |
" <td>70.53</td>\n", | |
" <td>76.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>22</th>\n", | |
" <td>Meghalaya</td>\n", | |
" <td>NaN</td>\n", | |
" <td>26.92</td>\n", | |
" <td>29.49</td>\n", | |
" <td>42.05</td>\n", | |
" <td>49.10</td>\n", | |
" <td>62.56</td>\n", | |
" <td>74.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>23</th>\n", | |
" <td>Mizoram</td>\n", | |
" <td>31.14</td>\n", | |
" <td>44.01</td>\n", | |
" <td>53.80</td>\n", | |
" <td>59.88</td>\n", | |
" <td>82.26</td>\n", | |
" <td>88.80</td>\n", | |
" <td>91.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>24</th>\n", | |
" <td>Nagaland</td>\n", | |
" <td>10.52</td>\n", | |
" <td>21.95</td>\n", | |
" <td>33.78</td>\n", | |
" <td>50.28</td>\n", | |
" <td>61.65</td>\n", | |
" <td>66.59</td>\n", | |
" <td>79.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25</th>\n", | |
" <td>Odisha</td>\n", | |
" <td>15.80</td>\n", | |
" <td>21.66</td>\n", | |
" <td>26.18</td>\n", | |
" <td>33.62</td>\n", | |
" <td>49.09</td>\n", | |
" <td>63.08</td>\n", | |
" <td>72.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>26</th>\n", | |
" <td>Puducherry</td>\n", | |
" <td>NaN</td>\n", | |
" <td>43.65</td>\n", | |
" <td>53.38</td>\n", | |
" <td>65.14</td>\n", | |
" <td>74.74</td>\n", | |
" <td>81.24</td>\n", | |
" <td>85.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>27</th>\n", | |
" <td>Punjab</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>34.12</td>\n", | |
" <td>43.37</td>\n", | |
" <td>58.51</td>\n", | |
" <td>69.65</td>\n", | |
" <td>75.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>28</th>\n", | |
" <td>Rajasthan</td>\n", | |
" <td>8.50</td>\n", | |
" <td>18.12</td>\n", | |
" <td>22.57</td>\n", | |
" <td>30.11</td>\n", | |
" <td>38.55</td>\n", | |
" <td>60.41</td>\n", | |
" <td>66.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>29</th>\n", | |
" <td>Sikkim</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>17.74</td>\n", | |
" <td>34.05</td>\n", | |
" <td>56.94</td>\n", | |
" <td>68.81</td>\n", | |
" <td>81.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>30</th>\n", | |
" <td>Tamil Nadu</td>\n", | |
" <td>NaN</td>\n", | |
" <td>36.39</td>\n", | |
" <td>45.40</td>\n", | |
" <td>54.39</td>\n", | |
" <td>62.66</td>\n", | |
" <td>73.45</td>\n", | |
" <td>80.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31</th>\n", | |
" <td>Tripura</td>\n", | |
" <td>NaN</td>\n", | |
" <td>20.24</td>\n", | |
" <td>30.98</td>\n", | |
" <td>50.10</td>\n", | |
" <td>60.44</td>\n", | |
" <td>73.19</td>\n", | |
" <td>87.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>32</th>\n", | |
" <td>Uttar Pradesh</td>\n", | |
" <td>12.02</td>\n", | |
" <td>20.87</td>\n", | |
" <td>23.99</td>\n", | |
" <td>32.65</td>\n", | |
" <td>40.71</td>\n", | |
" <td>56.27</td>\n", | |
" <td>67.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>33</th>\n", | |
" <td>Uttarakhand</td>\n", | |
" <td>18.93</td>\n", | |
" <td>18.05</td>\n", | |
" <td>33.26</td>\n", | |
" <td>46.06</td>\n", | |
" <td>57.75</td>\n", | |
" <td>71.62</td>\n", | |
" <td>78.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>34</th>\n", | |
" <td>West Bengal</td>\n", | |
" <td>24.61</td>\n", | |
" <td>34.46</td>\n", | |
" <td>38.86</td>\n", | |
" <td>48.65</td>\n", | |
" <td>57.70</td>\n", | |
" <td>68.64</td>\n", | |
" <td>76.3</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" State 1951 1961 1971 1981 1991 2001 \\\n", | |
"0 Andaman and Nicobar Islands 30.30 40.07 51.15 63.19 73.02 81.30 \n", | |
"1 Andhra Pradesh NaN 21.19 24.57 35.66 44.08 60.47 \n", | |
"2 Arunachal Pradesh NaN 7.13 11.29 25.55 41.59 54.34 \n", | |
"3 Assam 18.53 32.95 33.94 NaN 52.89 63.25 \n", | |
"4 Bihar 13.49 21.95 23.17 32.32 37.49 47.00 \n", | |
"5 Chandigarh NaN NaN 70.43 74.80 77.81 81.94 \n", | |
"6 Chhattisgarh 9.41 18.14 24.08 32.63 42.91 64.66 \n", | |
"7 Dadra and Nagar Haveli NaN NaN 18.13 32.90 40.71 57.63 \n", | |
"8 Daman and Diu NaN NaN NaN NaN 71.20 78.18 \n", | |
"9 Delhi NaN 61.95 65.08 71.94 75.29 81.67 \n", | |
"10 Goa 23.48 35.41 51.96 65.71 75.51 82.01 \n", | |
"11 Gujarat 21.82 31.47 36.95 44.92 61.29 69.14 \n", | |
"12 Haryana NaN NaN 25.71 37.13 55.85 67.91 \n", | |
"13 Himachal Pradesh NaN NaN NaN NaN 63.86 76.48 \n", | |
"14 Jammu and Kashmir NaN 12.95 21.71 30.64 NaN 55.52 \n", | |
"15 Jharkhand 12.93 21.14 23.87 35.03 41.39 53.56 \n", | |
"16 Karnataka NaN 29.80 36.83 46.21 56.04 66.64 \n", | |
"17 Kerala 47.18 55.08 69.75 78.85 89.81 90.86 \n", | |
"18 Lakshadweep 15.23 27.15 51.76 68.42 81.78 86.66 \n", | |
"19 Madhya Pradesh 13.16 21.41 27.27 38.63 44.67 63.74 \n", | |
"20 Maharashtra 27.91 35.08 45.77 57.24 64.87 76.88 \n", | |
"21 Manipur 12.57 36.04 38.47 49.66 59.89 70.53 \n", | |
"22 Meghalaya NaN 26.92 29.49 42.05 49.10 62.56 \n", | |
"23 Mizoram 31.14 44.01 53.80 59.88 82.26 88.80 \n", | |
"24 Nagaland 10.52 21.95 33.78 50.28 61.65 66.59 \n", | |
"25 Odisha 15.80 21.66 26.18 33.62 49.09 63.08 \n", | |
"26 Puducherry NaN 43.65 53.38 65.14 74.74 81.24 \n", | |
"27 Punjab NaN NaN 34.12 43.37 58.51 69.65 \n", | |
"28 Rajasthan 8.50 18.12 22.57 30.11 38.55 60.41 \n", | |
"29 Sikkim NaN NaN 17.74 34.05 56.94 68.81 \n", | |
"30 Tamil Nadu NaN 36.39 45.40 54.39 62.66 73.45 \n", | |
"31 Tripura NaN 20.24 30.98 50.10 60.44 73.19 \n", | |
"32 Uttar Pradesh 12.02 20.87 23.99 32.65 40.71 56.27 \n", | |
"33 Uttarakhand 18.93 18.05 33.26 46.06 57.75 71.62 \n", | |
"34 West Bengal 24.61 34.46 38.86 48.65 57.70 68.64 \n", | |
"\n", | |
" 2011 \n", | |
"0 86.6 \n", | |
"1 67.0 \n", | |
"2 65.4 \n", | |
"3 72.2 \n", | |
"4 61.8 \n", | |
"5 86.0 \n", | |
"6 70.3 \n", | |
"7 76.2 \n", | |
"8 87.1 \n", | |
"9 86.2 \n", | |
"10 88.7 \n", | |
"11 78.0 \n", | |
"12 75.6 \n", | |
"13 82.8 \n", | |
"14 67.2 \n", | |
"15 66.4 \n", | |
"16 75.4 \n", | |
"17 94.0 \n", | |
"18 91.8 \n", | |
"19 69.3 \n", | |
"20 82.3 \n", | |
"21 76.9 \n", | |
"22 74.4 \n", | |
"23 91.3 \n", | |
"24 79.6 \n", | |
"25 72.9 \n", | |
"26 85.8 \n", | |
"27 75.8 \n", | |
"28 66.1 \n", | |
"29 81.4 \n", | |
"30 80.1 \n", | |
"31 87.2 \n", | |
"32 67.7 \n", | |
"33 78.8 \n", | |
"34 76.3 " | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### List the Dataframe\n", | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 47, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"### A new variable name 'subset' to store only ['State','1991', '2001', '2011'] coloumn.\n", | |
"subset = df[['State','1991', '2001', '2011']]\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 48, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>State</th>\n", | |
" <th>1991</th>\n", | |
" <th>2001</th>\n", | |
" <th>2011</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>Andaman and Nicobar Islands</td>\n", | |
" <td>73.02</td>\n", | |
" <td>81.30</td>\n", | |
" <td>86.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>Andhra Pradesh</td>\n", | |
" <td>44.08</td>\n", | |
" <td>60.47</td>\n", | |
" <td>67.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>Arunachal Pradesh</td>\n", | |
" <td>41.59</td>\n", | |
" <td>54.34</td>\n", | |
" <td>65.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Assam</td>\n", | |
" <td>52.89</td>\n", | |
" <td>63.25</td>\n", | |
" <td>72.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Bihar</td>\n", | |
" <td>37.49</td>\n", | |
" <td>47.00</td>\n", | |
" <td>61.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>Chandigarh</td>\n", | |
" <td>77.81</td>\n", | |
" <td>81.94</td>\n", | |
" <td>86.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>Chhattisgarh</td>\n", | |
" <td>42.91</td>\n", | |
" <td>64.66</td>\n", | |
" <td>70.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>Dadra and Nagar Haveli</td>\n", | |
" <td>40.71</td>\n", | |
" <td>57.63</td>\n", | |
" <td>76.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>Daman and Diu</td>\n", | |
" <td>71.20</td>\n", | |
" <td>78.18</td>\n", | |
" <td>87.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>Delhi</td>\n", | |
" <td>75.29</td>\n", | |
" <td>81.67</td>\n", | |
" <td>86.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>Goa</td>\n", | |
" <td>75.51</td>\n", | |
" <td>82.01</td>\n", | |
" <td>88.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>Gujarat</td>\n", | |
" <td>61.29</td>\n", | |
" <td>69.14</td>\n", | |
" <td>78.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>12</th>\n", | |
" <td>Haryana</td>\n", | |
" <td>55.85</td>\n", | |
" <td>67.91</td>\n", | |
" <td>75.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>13</th>\n", | |
" <td>Himachal Pradesh</td>\n", | |
" <td>63.86</td>\n", | |
" <td>76.48</td>\n", | |
" <td>82.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>14</th>\n", | |
" <td>Jammu and Kashmir</td>\n", | |
" <td>NaN</td>\n", | |
" <td>55.52</td>\n", | |
" <td>67.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>Jharkhand</td>\n", | |
" <td>41.39</td>\n", | |
" <td>53.56</td>\n", | |
" <td>66.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>16</th>\n", | |
" <td>Karnataka</td>\n", | |
" <td>56.04</td>\n", | |
" <td>66.64</td>\n", | |
" <td>75.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>17</th>\n", | |
" <td>Kerala</td>\n", | |
" <td>89.81</td>\n", | |
" <td>90.86</td>\n", | |
" <td>94.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>18</th>\n", | |
" <td>Lakshadweep</td>\n", | |
" <td>81.78</td>\n", | |
" <td>86.66</td>\n", | |
" <td>91.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>19</th>\n", | |
" <td>Madhya Pradesh</td>\n", | |
" <td>44.67</td>\n", | |
" <td>63.74</td>\n", | |
" <td>69.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>20</th>\n", | |
" <td>Maharashtra</td>\n", | |
" <td>64.87</td>\n", | |
" <td>76.88</td>\n", | |
" <td>82.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>21</th>\n", | |
" <td>Manipur</td>\n", | |
" <td>59.89</td>\n", | |
" <td>70.53</td>\n", | |
" <td>76.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>22</th>\n", | |
" <td>Meghalaya</td>\n", | |
" <td>49.10</td>\n", | |
" <td>62.56</td>\n", | |
" <td>74.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>23</th>\n", | |
" <td>Mizoram</td>\n", | |
" <td>82.26</td>\n", | |
" <td>88.80</td>\n", | |
" <td>91.3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>24</th>\n", | |
" <td>Nagaland</td>\n", | |
" <td>61.65</td>\n", | |
" <td>66.59</td>\n", | |
" <td>79.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25</th>\n", | |
" <td>Odisha</td>\n", | |
" <td>49.09</td>\n", | |
" <td>63.08</td>\n", | |
" <td>72.9</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>26</th>\n", | |
" <td>Puducherry</td>\n", | |
" <td>74.74</td>\n", | |
" <td>81.24</td>\n", | |
" <td>85.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>27</th>\n", | |
" <td>Punjab</td>\n", | |
" <td>58.51</td>\n", | |
" <td>69.65</td>\n", | |
" <td>75.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>28</th>\n", | |
" <td>Rajasthan</td>\n", | |
" <td>38.55</td>\n", | |
" <td>60.41</td>\n", | |
" <td>66.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>29</th>\n", | |
" <td>Sikkim</td>\n", | |
" <td>56.94</td>\n", | |
" <td>68.81</td>\n", | |
" <td>81.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>30</th>\n", | |
" <td>Tamil Nadu</td>\n", | |
" <td>62.66</td>\n", | |
" <td>73.45</td>\n", | |
" <td>80.1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31</th>\n", | |
" <td>Tripura</td>\n", | |
" <td>60.44</td>\n", | |
" <td>73.19</td>\n", | |
" <td>87.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>32</th>\n", | |
" <td>Uttar Pradesh</td>\n", | |
" <td>40.71</td>\n", | |
" <td>56.27</td>\n", | |
" <td>67.7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>33</th>\n", | |
" <td>Uttarakhand</td>\n", | |
" <td>57.75</td>\n", | |
" <td>71.62</td>\n", | |
" <td>78.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>34</th>\n", | |
" <td>West Bengal</td>\n", | |
" <td>57.70</td>\n", | |
" <td>68.64</td>\n", | |
" <td>76.3</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" State 1991 2001 2011\n", | |
"0 Andaman and Nicobar Islands 73.02 81.30 86.6\n", | |
"1 Andhra Pradesh 44.08 60.47 67.0\n", | |
"2 Arunachal Pradesh 41.59 54.34 65.4\n", | |
"3 Assam 52.89 63.25 72.2\n", | |
"4 Bihar 37.49 47.00 61.8\n", | |
"5 Chandigarh 77.81 81.94 86.0\n", | |
"6 Chhattisgarh 42.91 64.66 70.3\n", | |
"7 Dadra and Nagar Haveli 40.71 57.63 76.2\n", | |
"8 Daman and Diu 71.20 78.18 87.1\n", | |
"9 Delhi 75.29 81.67 86.2\n", | |
"10 Goa 75.51 82.01 88.7\n", | |
"11 Gujarat 61.29 69.14 78.0\n", | |
"12 Haryana 55.85 67.91 75.6\n", | |
"13 Himachal Pradesh 63.86 76.48 82.8\n", | |
"14 Jammu and Kashmir NaN 55.52 67.2\n", | |
"15 Jharkhand 41.39 53.56 66.4\n", | |
"16 Karnataka 56.04 66.64 75.4\n", | |
"17 Kerala 89.81 90.86 94.0\n", | |
"18 Lakshadweep 81.78 86.66 91.8\n", | |
"19 Madhya Pradesh 44.67 63.74 69.3\n", | |
"20 Maharashtra 64.87 76.88 82.3\n", | |
"21 Manipur 59.89 70.53 76.9\n", | |
"22 Meghalaya 49.10 62.56 74.4\n", | |
"23 Mizoram 82.26 88.80 91.3\n", | |
"24 Nagaland 61.65 66.59 79.6\n", | |
"25 Odisha 49.09 63.08 72.9\n", | |
"26 Puducherry 74.74 81.24 85.8\n", | |
"27 Punjab 58.51 69.65 75.8\n", | |
"28 Rajasthan 38.55 60.41 66.1\n", | |
"29 Sikkim 56.94 68.81 81.4\n", | |
"30 Tamil Nadu 62.66 73.45 80.1\n", | |
"31 Tripura 60.44 73.19 87.2\n", | |
"32 Uttar Pradesh 40.71 56.27 67.7\n", | |
"33 Uttarakhand 57.75 71.62 78.8\n", | |
"34 West Bengal 57.70 68.64 76.3" | |
] | |
}, | |
"execution_count": 48, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### The output of the variable.\n", | |
"subset" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"State Delhi\n", | |
"1991 75.29\n", | |
"2001 81.67\n", | |
"2011 86.2\n", | |
"Name: 9, dtype: object" | |
] | |
}, | |
"execution_count": 23, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### Content of Row 10 in variable subset.\n", | |
"subset.loc[9]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>State</th>\n", | |
" <th>1991</th>\n", | |
" <th>2001</th>\n", | |
" <th>2011</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Assam</td>\n", | |
" <td>52.89</td>\n", | |
" <td>63.25</td>\n", | |
" <td>72.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Bihar</td>\n", | |
" <td>37.49</td>\n", | |
" <td>47.00</td>\n", | |
" <td>61.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>Gujarat</td>\n", | |
" <td>61.29</td>\n", | |
" <td>69.14</td>\n", | |
" <td>78.0</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" State 1991 2001 2011\n", | |
"3 Assam 52.89 63.25 72.2\n", | |
"4 Bihar 37.49 47.00 61.8\n", | |
"11 Gujarat 61.29 69.14 78.0" | |
] | |
}, | |
"execution_count": 31, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"### This is what we needed, the dataframe with Assam, Bihar and Gujarat for year 1991, 2001 and 2011.\n", | |
"subset.loc[[3,4,11]]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"data = subset.loc[[3,4,11]]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>State</th>\n", | |
" <th>1991</th>\n", | |
" <th>2001</th>\n", | |
" <th>2011</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Assam</td>\n", | |
" <td>52.89</td>\n", | |
" <td>63.25</td>\n", | |
" <td>72.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>Bihar</td>\n", | |
" <td>37.49</td>\n", | |
" <td>47.00</td>\n", | |
" <td>61.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>Gujarat</td>\n", | |
" <td>61.29</td>\n", | |
" <td>69.14</td>\n", | |
" <td>78.0</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" State 1991 2001 2011\n", | |
"3 Assam 52.89 63.25 72.2\n", | |
"4 Bihar 37.49 47.00 61.8\n", | |
"11 Gujarat 61.29 69.14 78.0" | |
] | |
}, | |
"execution_count": 36, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"data" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.10" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment