Python for Science and Engg: Basic data processing (session 3)
36 Pages
English

Python for Science and Engg: Basic data processing (session 3)

-

Downloading requires you to have access to the YouScribe library
Learn all about the services we offer

Description

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 ...

Subjects

Informations

Published by
Published 27 June 2011
Reads 195
Language English
OFSSE
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
I(EESSOFsicalmetang-ClasohdThIeomBebamnyMaeSm)pauttiitntgstics5/36oC
In []: In []: ....: ....:
total = 0 forging_stli: total += g
In []: In []:
g_mean = total / len(g_list) print’Mean: ’, g_mean
g_mean = sum(g_list) / print’Mean: ’, g_mean
63/6scitsitatSy)baomTBIIE(SEOS
[]: []:
In In
(nelodthFg_list)utinCompnaemehtglS-gnaeMimlyhtigmeedovpr
EESSFOmbBoIT(I
[]: []:
g_mean = mean(g_list) print’Mean: ’, g mean _
6
10 m
In In
atityaS)7s3/tscieanM-OnglinernemoCituphtgnaeme
ouinumolgvinssceeniltuOatadsPor6
Computing the mean
1
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 dotenecifstatistical 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 ’;’
leaStructureofthenivglomuniuodstaroPssce
cessProethofretuuctraStadsuonimulovgnimoBTII(EESSOF11cstiisatSty)ba
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)
15 m
A;015163;JOSEPH RAJ S;083;042;47;AA;72;244;;;
3/6..le.