Skip to content

Instantly share code, notes, and snippets.

@izmailovpavel
Last active December 1, 2016 18:35
Show Gist options
  • Save izmailovpavel/46eaa6257885a1b7c6ed36b0e563f071 to your computer and use it in GitHub Desktop.
Save izmailovpavel/46eaa6257885a1b7c6ed36b0e563f071 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"marks_1 = [\n",
" ['Calculus I', 5, 7],\n",
" ['Algorithms', 4, 4],\n",
" ['Linear Algebra I', 5, 7],\n",
" ['Russian History', 4, 4],\n",
" ['Computer Practice I', 5, 3]\n",
"]\n",
"marks_2 = [\n",
" ['Assembler', 4, 3],\n",
" ['Discrete Math', 5, 4],\n",
" ['Linear Algerbra II', 5, 7],\n",
" ['Calculus II', 5, 7],\n",
" ['Computer Practice II', 4, 3]\n",
"]\n",
"marks_3 = [\n",
" ['OS', 5, 3],\n",
" ['Philosophy', 5, 2],\n",
" ['Numerical Methods Intro', 5, 3],\n",
" ['Calculus III', 4, 7],\n",
" ['Computer Practice III', 4, 2],\n",
" ['Mechanics', 5, 4]\n",
"]\n",
"marks_4 = [\n",
" ['Ordinary Differential Equations', 5, 4],\n",
" ['Probability theory', 5, 4],\n",
" ['Programming Systems', 4, 3],\n",
" ['Foreign Language', 5, 3],\n",
" ['Computer Practice IV', 5, 3],\n",
" ['Calculus IV', 4, 6]\n",
"]\n",
"marks_5 = [\n",
" ['Equations of Mathematical Physics', 5, 4],\n",
" ['Pattern Recognition I', 5, 2],\n",
" ['Computer Practice V', 5, 2],\n",
" ['Optimal Control', 5, 2],\n",
" ['Economic Sciences', 5, 4],\n",
" ['Statistical Physics', 5, 3]\n",
"]\n",
"marks_6 = [\n",
" ['Numerical Methods', 4, 4],\n",
" ['Pattern Recognition II', 5, 3],\n",
" ['Applied Algebra', 5, 3],\n",
" ['Image Processing', 5, 2],\n",
" ['Computer Practice VI', 5, 2],\n",
" ['Optimization Methods', 5, 3],\n",
" ['Course Work', 5, 3]\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"marks_lst = sum([marks_1, marks_2, marks_3, \n",
" marks_4, marks_5, marks_6], [])"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"marks = pd.DataFrame(marks_lst, columns=['Name', 'Mark', 'Credits'])"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Mark</th>\n",
" <th>Credits</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Calculus I</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Algorithms</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Linear Algebra I</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Russian History</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Computer Practice I</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Assembler</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Discrete Math</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Linear Algerbra II</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Calculus II</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Computer Practice II</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>OS</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Philosophy</td>\n",
" <td>5</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>Numerical Methods Intro</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>Calculus III</td>\n",
" <td>4</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>Computer Practice III</td>\n",
" <td>4</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>Mechanics</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>Ordinary Differential Equations</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>Probability theory</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>Programming Systems</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>Foreign Language</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>Computer Practice IV</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>Calculus IV</td>\n",
" <td>4</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>Equations of Mathematical Physics</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>Pattern Recognition I</td>\n",
" <td>5</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>Computer Practice V</td>\n",
" <td>5</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>Optimal Control</td>\n",
" <td>5</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>Economic Sciences</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>Statistical Physics</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>Numerical Methods</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>Pattern Recognition II</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>Applied Algebra</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>Image Processing</td>\n",
" <td>5</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>Computer Practice VI</td>\n",
" <td>5</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>Optimization Methods</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>Course Work</td>\n",
" <td>5</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Mark Credits\n",
"0 Calculus I 5 7\n",
"1 Algorithms 4 4\n",
"2 Linear Algebra I 5 7\n",
"3 Russian History 4 4\n",
"4 Computer Practice I 5 3\n",
"5 Assembler 4 3\n",
"6 Discrete Math 5 4\n",
"7 Linear Algerbra II 5 7\n",
"8 Calculus II 5 7\n",
"9 Computer Practice II 4 3\n",
"10 OS 5 3\n",
"11 Philosophy 5 2\n",
"12 Numerical Methods Intro 5 3\n",
"13 Calculus III 4 7\n",
"14 Computer Practice III 4 2\n",
"15 Mechanics 5 4\n",
"16 Ordinary Differential Equations 5 4\n",
"17 Probability theory 5 4\n",
"18 Programming Systems 4 3\n",
"19 Foreign Language 5 3\n",
"20 Computer Practice IV 5 3\n",
"21 Calculus IV 4 6\n",
"22 Equations of Mathematical Physics 5 4\n",
"23 Pattern Recognition I 5 2\n",
"24 Computer Practice V 5 2\n",
"25 Optimal Control 5 2\n",
"26 Economic Sciences 5 4\n",
"27 Statistical Physics 5 3\n",
"28 Numerical Methods 4 4\n",
"29 Pattern Recognition II 5 3\n",
"30 Applied Algebra 5 3\n",
"31 Image Processing 5 2\n",
"32 Computer Practice VI 5 2\n",
"33 Optimization Methods 5 3\n",
"34 Course Work 5 3"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"marks"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"GPA_pure = marks['Mark'].mean()\n",
"GPA_credit = sum(marks['Mark'] * marks['Credits'] / marks['Credits'].sum())"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Pure GPA:\t\t 4.74285714286 / 5 = 3.79428571429 / 4\n",
"GPA with Credits:\t 4.72307692308 / 5 = 3.77846153846 / 4\n"
]
}
],
"source": [
"print('Pure GPA:\\t\\t', GPA_pure,'/ 5 =', GPA_pure * 4/5, '/ 4')\n",
"print('GPA with Credits:\\t', GPA_credit,'/ 5 =', GPA_credit * 4/5, '/ 4')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment