Python for Science and Engg:Basic data processingFOSSEEDepartment of Aerospace EngineeringIIT BombaySciPy 2010, Introductory tutorials,Day 1, Session 3FOSSEE (IIT Bombay) Statistics 1 / 36Computing the meanOutline1 Computing the mean2 Processing voluminous dataData processingDictionariesVisualizing dataObtaining statisticsFOSSEE (IIT Bombay) Statistics 2 / 36Computing the meanValue of acceleration due to gravity?We already havependulum.txtqLWe know that T = 2g24 LSo g= 2TCalculate g - acceleration due to gravity for eachpair of L and THence calculate mean gFOSSEE (IIT Bombay) Statistics 3 / 36Computing the meanAcceleration due to gravity - g. . .In []: g_list = []In []: for line in open(’pendulum.txt’):.... point = line.split() L = float(point[0]).... t = float(point[1]) g = 4 pi pi L / (t t)* * * *.... g_list.append(g)FOSSEE (IIT Bombay) Statistics 4 / 36Computing the meanMean g - Classical methodIn []: total = 0In []: for g in g_list:....: total += gIn []: g_mean = total / len(g_list)In []: print ’Mean: ’, g_meanFOSSEE (IIT Bombay) Statistics 5 / 36Computing the meanMean g - Slightly improved methodIn []: g_mean = sum(g_list) / len(g_list)In []: print ’Mean: ’, g_meanFOSSEE (IIT Bombay) Statistics 6 / 36Computing the meanMean g - One linerIn []: g_mean = mean(g_list)In []: print ’Mean: ’, g_mean10 mFOSSEE (IIT Bombay) Statistics 7 / 36Processing voluminous dataOutline1 Computing the mean2 Processing voluminous ...
Python for Science and Engg: Basic data processing
EI(ITBom
FOSSEE
Department of Aerospace Engineering IIT Bombay
SciPy 2010, Introductory tutorials, Day 1, Session 3
bay)Statistics1/63
S)yabmoBcitsitatFOIT(IEESS6
1
Computing the mean
s2/3
2
Processing voluminous Data processing Dictionaries Visualizing data Obtaining statistics
data
upitCmolinenOutemeangth
SSOFEE(IITBombay)Staittsci3s3/6
We already havenepttxm.ludu We know thatT=2πqgL
Sog4π2L =T2 Calculateg- acceleration due to gravity for each pair ofLandT Hence calculate meang
hegtanmempCoinutgravity?ionduetoccleretaaVuloeaf
Computing the mean Acceleration due to gravity -g. . . In []: g_ ist = [] l In []:forlineinopen(’txpe’.tumulnd): .... point = line.split() .... L = float(point[0]) .... t = float(point[1]) .... g = 4 * pi * pi * L / (t * t) .... g_list.append(g) FOSSEE (IIT Bombay) Statistics 4 / 36
Processing voluminous Data processing Dictionaries Visualizing data Obtaining statistics
2
data
EESSOFbmoBTII(tita)Say/3s8icst
corPsiesvongmiluusnognissecoprtadaonreMotada
We have a huge data file–180,000 records. How do we doteneciffistatistical computations, i.e. find mean, median, standard deviation etc.; How do we draw pie charts?
atisy)St9/36ticsES(EFSOmoabIIBT
icst0/s1)SaytitaTII(bmoBOFEESS
A;015162;JENIL T P;081;060;77;41;74;333;P;;
63
Understanding the structure of.tc1xtsls Each line in the file has a student’s details(record) Each record consists of fields separated by ’;’
Each record consists of: Region Code Roll Number Name Marks of 5 subjects: second lang, first lang., Math, Science, Social Studies Total marks Pass/Fail (P/F) Withheld (W)