<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC3%2FStatistics%2FEnglish-timed</id>
		<title>Python-3.4.3/C3/Statistics/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC3%2FStatistics%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Statistics/English-timed&amp;action=history"/>
		<updated>2026-05-17T14:26:25Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Statistics/English-timed&amp;diff=47644&amp;oldid=prev</id>
		<title>PoojaMoolya: Created page with &quot; {|border=1 | &lt;center&gt;'''Time'''&lt;/center&gt; | &lt;center&gt;'''Narration'''&lt;/center&gt;  |- | 00:01 | Hello Friends. Welcome to the tutorial on &quot;'''Statistics'''” using '''Python'''  |...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Statistics/English-timed&amp;diff=47644&amp;oldid=prev"/>
				<updated>2019-05-31T09:58:54Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; {|border=1 | &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt; | &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;  |- | 00:01 | Hello Friends. Welcome to the tutorial on &amp;quot;&amp;#039;&amp;#039;&amp;#039;Statistics&amp;#039;&amp;#039;&amp;#039;” using &amp;#039;&amp;#039;&amp;#039;Python&amp;#039;&amp;#039;&amp;#039;  |...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
{|border=1&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Time'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Narration'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:01&lt;br /&gt;
| Hello Friends. Welcome to the tutorial on &amp;quot;'''Statistics'''” using '''Python'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:07&lt;br /&gt;
| At the end of this tutorial, you will be able to - Do '''statistical''' operations in '''Python'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:14&lt;br /&gt;
|  '''Sum''' a set of numbers and Find their '''mean, median''' and '''standard deviation'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:22&lt;br /&gt;
| To record this tutorial, I am using '''Ubuntu Linux 16.04''' operating system&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:29&lt;br /&gt;
| '''Python 3.4.3 '''and '''IPython 5.1.0'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:36&lt;br /&gt;
| To practise this tutorial, you should know how to load data from files&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:42 &lt;br /&gt;
| use '''Lists''' and access parts of '''Arrays'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:47&lt;br /&gt;
|If not, see the pre-requisite '''Python''' tutorials on this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:53&lt;br /&gt;
| For this tutorial, we will use the data file '''student_record.txt '''which we used in the earlier tutorial. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:03&lt;br /&gt;
|You can also find this file in the '''Code Files''' link of this tutorial. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:08&lt;br /&gt;
|Please download it in '''Home directory''' and use it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:12&lt;br /&gt;
| We will use mathematical and logical operations on this '''array structured file'''.&lt;br /&gt;
&lt;br /&gt;
For this, we need to install '''Numpy'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:22&lt;br /&gt;
| '''NumPy''', stands for '''Numerical Python.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:26&lt;br /&gt;
|It is a library consisting of '''pre-compiled functions''' for mathematical and numerical routines.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:33&lt;br /&gt;
|'''NumPy''' has to be installed separately.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:37&lt;br /&gt;
| Let us first open the '''Terminal '''by pressing '''Ctrl+Alt+T '''keys simultaneously.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:45&lt;br /&gt;
| Let us install latest '''pip'''.&lt;br /&gt;
&lt;br /&gt;
'''pip''' command is used to install''' python libraries.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:53&lt;br /&gt;
|Type, '''sudo apt-get install python3  hyphen pip''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:03&lt;br /&gt;
|You need to have '''root''' access for installation as it asks for '''admin password'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:15&lt;br /&gt;
|  Next, we need to install '''numpy library''' as we will be using '''numpy library''' throughout the tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:24&lt;br /&gt;
|Type, '''sudo pip3 install numpy '''is equal to is equal to''' 1.13.3 '''and press''' Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:38&lt;br /&gt;
|  The installation is completed successfully. We can see the '''terminal prompt''' without any error. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:47&lt;br /&gt;
| Next we will learn about '''loadtxt() function.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:52&lt;br /&gt;
|To get the data as an '''array''', we use the '''loadtxt() function.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:58&lt;br /&gt;
|For '''loadtxt() function''', we need to '''import numpy library''' first.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:04&lt;br /&gt;
| Switch back to the '''terminal'''.Now, type '''ipython3''' and press '''Enter'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:12&lt;br /&gt;
| Type '''import numpy as np''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
Where '''np''' is alias to '''numpy''' and it can be any name.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:24&lt;br /&gt;
| Let us load the data from the file '''student_record.txt '''as an '''array'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:32&lt;br /&gt;
|Type, '''L''' is equal to '''np dot loadtxt''' inside '''parentheses''' inside quotes '''student_record.txt''' comma '''usecols''' is equal to inside '''parentheses''' 3 comma 4 comma 5 comma 6 comma 7 comma '''delimiter''' is equal to inside quotes '''semicolon''' and Press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:04&lt;br /&gt;
|Type''' L '''and press''' Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:07&lt;br /&gt;
| We get the '''output''' in the form of an '''array'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:11&lt;br /&gt;
| '''loadtxt''' loads data from an external file. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:16&lt;br /&gt;
|&lt;br /&gt;
'''Delimiter''' specifies the kind of character that the '''fields''' of data is separated by. &lt;br /&gt;
&lt;br /&gt;
'''usecols''' specifies the '''columns''' to be used. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:27&lt;br /&gt;
|'''loadtxt, delimiter''' and '''usecols''' are '''keywords'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:33&lt;br /&gt;
| So '''columns''' 3,4,5,6,7 from '''student_record.txt '''are loaded here. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:42&lt;br /&gt;
|The 'comma' between '''column numbers''' is added because '''usecols''' is a '''sequence'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:49&lt;br /&gt;
| As we can see '''L''' is an '''array'''. We can get the shape of this '''array''' using '''shape.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:58&lt;br /&gt;
| Type, '''L dot shape '''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:04&lt;br /&gt;
| We get a '''tuple''' giving the numbers of '''rows''' and '''columns''' respectively.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:11&lt;br /&gt;
|In this example, the array '''L '''has one lakh eighty five thousand six hundred and sixty seven rows and 5 columns.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:22&lt;br /&gt;
| Let us switch back to the '''student_record.txt''' file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:28&lt;br /&gt;
| Let us start applying statistical operations on these. &lt;br /&gt;
&lt;br /&gt;
How do you find the sum of marks of all subjects for the first student?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:39&lt;br /&gt;
| Switch back to the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
To access the first row in an '''array''', we will type '''L '''inside square brackets '''0 '''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:54&lt;br /&gt;
| Now to sum this, type, '''totalmarks '''is equal to '''sum '''inside parentheses '''L '''inside square brackets '''0 ''' and Press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:09&lt;br /&gt;
| Type '''totalmarks '''and press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
We got sum of marks of all subjects of the first student.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:19&lt;br /&gt;
| Now to get the '''mean''' we can divide the '''totalmarks''' by the length of the '''array.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:26&lt;br /&gt;
|Type, '''totalmarks '''divided by '''len''' inside parentheses '''L''' inside square brackets '''''0 '''and press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:40&lt;br /&gt;
| Or simply use the '''function mean'''. Type '''np dot mean''' inside parentheses '''L '''inside square brackets '''0 '''and press''' Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:55&lt;br /&gt;
| But we have such a large '''data''' '''set'''. &lt;br /&gt;
&lt;br /&gt;
And calculating the '''mean''' for each student one by one is time consuming. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:04&lt;br /&gt;
|Is there a way to reduce the work?&lt;br /&gt;
&lt;br /&gt;
For this, we will look into the '''documentation''' of '''mean.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:12&lt;br /&gt;
|Type, '''np dot mean questionmark '''and press Enter''.'' Read the text for more information.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:23&lt;br /&gt;
| Type '''q '''to exit the documentation.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:28&lt;br /&gt;
| In the above example, '''L''' is a '''two dimensional array '''like '''matrix'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:35&lt;br /&gt;
|We can calculate the '''mean''' across each of the '''axis''' of the '''array'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:41&lt;br /&gt;
|The '''axis''' of '''rows''' is referred by 0 and '''columns''' by 1. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:48&lt;br /&gt;
|To calculate '''mean''' across all '''columns''', we have to pass extra parameter 1 for the '''axis'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:57&lt;br /&gt;
| Switch back to the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:00&lt;br /&gt;
|Let us calculate, '''mean''' of the marks scored by all the students for each subject. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:07&lt;br /&gt;
|Type '''np dot mean '''inside parentheses '''L  comma 0''' ''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:18&lt;br /&gt;
| Next, we will calculate the '''median''' of English marks for all the students. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:25&lt;br /&gt;
|Type '''L '''inside square brackets '''colon comma 0 '''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:35&lt;br /&gt;
|Note '''colon comma zero''' displays first '''column''' in the '''array''' that is, English Mark.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:45&lt;br /&gt;
| To get the '''median''' we will simply use the '''function median'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:51&lt;br /&gt;
|Type '''np dot median '''inside parentheses '''L '''inside square brackets '''colon''' comma '''0 '''&lt;br /&gt;
&lt;br /&gt;
Press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:04&lt;br /&gt;
| For all the subjects, we can calculate '''median''' across all '''rows''' using '''median function''' as shown here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:13&lt;br /&gt;
|Type '''np dot median '''inside parentheses '''L comma 0'''&lt;br /&gt;
&lt;br /&gt;
Press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:24&lt;br /&gt;
| Similarly to calculate '''standard''' '''deviation''' we will use the '''function std'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:31&lt;br /&gt;
|Standard deviation for English subject can be found by typing '''np  dot std '''inside parentheses '''L '''inside square brackets '''colon comma 0'''. Press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:50&lt;br /&gt;
| And for all '''rows''', we do, '''np dot std '''inside parentheses '''L comma 0 '''and press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:03&lt;br /&gt;
| Pause the video here, try out the following exercise and resume the video.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:09&lt;br /&gt;
| Refer to the file''' football.txt''', that is available in the '''Code Files''' link of this tutorial. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:18&lt;br /&gt;
|Download and save the file in the '''present working directory'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:23&lt;br /&gt;
|Currently the '''present working directory''' is the '''Home directory.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:28&lt;br /&gt;
| In '''football.txt''', the first column is '''player name''', &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:34&lt;br /&gt;
| Second is '''goals''' '''at home''' and third is '''goals away'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:42&lt;br /&gt;
|  Find the total goals for each player &lt;br /&gt;
&lt;br /&gt;
'''Mean''' of home and goals away&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:50&lt;br /&gt;
| '''Standard deviation''' of home and goals away&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:55&lt;br /&gt;
| Switch to the terminal.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:58&lt;br /&gt;
|The solution is, first, type, '''L''' is equal to '''np dot loadtxt''' inside parentheses inside quotes '''football.txt comma usecols''' is equal to inside parentheses '''1 comma 2 comma delimiter''' is equal to inside quotes '''comma'''. Press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:31&lt;br /&gt;
|'''np dot sum '''inside parentheses '''L comma 1 '''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:39&lt;br /&gt;
| The answer for the second, '''np dot mean '''inside parentheses '''L comma 0 '''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:50&lt;br /&gt;
| Third, '''np dot std '''inside parentheses '''L comma 0 '''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:59&lt;br /&gt;
| This brings us to the end of the tutorial. &lt;br /&gt;
&lt;br /&gt;
In this tutorial, we have learnt to do the standard '''statistical operations''' like:  '''sum''', '''mean''', '''median''' and '''standard deviation''' in '''Python'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 12:18&lt;br /&gt;
| Here are some self assessment questions for you to solve.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 12:23&lt;br /&gt;
| Given a '''two dimensional list '''as shown, how do you calculate the '''mean''' of each row?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 12:32&lt;br /&gt;
| Second. Calculate the '''median''' of the given '''list'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 12:37&lt;br /&gt;
| Third. There is a '''file''' with 6 '''columns'''. But we want to load text only from '''columns''' 2,3,4,5. &lt;br /&gt;
&lt;br /&gt;
How do we specify that?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 12:51&lt;br /&gt;
| And the answers,&lt;br /&gt;
&lt;br /&gt;
To get the '''mean''' of each '''row''', we just pass 1 as the second '''parameter''' to the '''function mean'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 13:02&lt;br /&gt;
| '''np.mean '''inside parentheses''' two_dimensional_list comma 1'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 13:11&lt;br /&gt;
| We use the '''function median''' to calculate the '''median''' of the '''list'''&lt;br /&gt;
&lt;br /&gt;
'''np.median '''inside parentheses '''student_marks'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 13:24&lt;br /&gt;
|Third, To specify the particular '''columns''' of a file, we use the parameter '''usecols '''is equal to inside parentheses '''2, 3, 4, 5'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 13:39&lt;br /&gt;
| Please post your timed queries in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 13:43&lt;br /&gt;
| Please post your general queries on '''Python''' in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 13:48&lt;br /&gt;
| FOSSEE team coordinates the TBC project.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 13:53&lt;br /&gt;
| Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.&lt;br /&gt;
&lt;br /&gt;
For more details, visit this website. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 14:05&lt;br /&gt;
| Thats it for the tutorial.&lt;br /&gt;
&lt;br /&gt;
This is Trupti Kini from IIT Bombay signing off. Thank you.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>PoojaMoolya</name></author>	</entry>

	</feed>