Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
16 views
DataSeries Notes File
Uploaded by
nilampatelhanny
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save DataSeries Notes File For Later
Download
Save
Save DataSeries Notes File For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
16 views
DataSeries Notes File
Uploaded by
nilampatelhanny
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save DataSeries Notes File For Later
Carousel Previous
Carousel Next
Save
Save DataSeries Notes File For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 12
Search
Fullscreen
In[33)) import pandas as pd ‘Empty Data Series crested = pd-series) rina) Series), dtype:float64) CAUsers\Welcome\\AppData\Local\ Temp\ipykernel_16720\1694814139 py'5: FutureWorning: The default dtype for empty ‘Series wll be ‘object’ instead of ‘float64” ina future version. Specify @ type explicitly Yo silence this warning ‘= pdSeries() n[31} import pandas as pd import numpy asp ‘#Data can be multipled by list form only FetoybifedJe'F] iC Eien, “aralie',Bommie') Series(deta= O°2, index = F) Sindexsname = ‘The Vanpire Diaries primes). prinv(Sindex) ‘The Vampire Diaries a” Elena Caroline © Bonnie d Elena © Caroline Bonnie ctype: object Index(('a','b' "FJ. dtypes'object’, name="The Vampire Diaries’) Tn[22) import pandas as pd Import rumpy os np ‘#Any data Series can be given name by ‘index name function = [ Hom’, ‘Dhan "Nilo, Pravin’ S=paSeries(L) Sindexname = 'My for pines) My family 0 Hanny 1 Dhani 2 Nilam 3 Pravin type: object In[I7}. import pandas as pd import numpy a: ip #We can slice aut info from range function by default index number F = {'Phoebe', ‘Monica’, ‘Rechel' Ross’, ‘Chandler’, Joey'] S = pd.Series(data = F) Siindexname = "FR. T.E.N.D.5." prints) prim(St03) FRIENDS. Phoebe 1 Monica 2 Rachel 3 Ross 4 Chandler 5 Joey type: object FRIENDS. 0 Phoebe 1 Monica 2 Rachel ype: objectIn(27} In (30) Ins} Import pandas os pd Import numpy os np # we can give index and data by our choice , nat default numbers names = CPoyel, “Sujata age = [45.27.35] info = pd Series(index = names, dot prinv(info) ‘Tayo") ‘This cn be used to assign index to respective data series ‘Hand create data zeres directly by [] form A= pa Series((44,57, 62,74, 89)) Aindex=('a',"b' 73 'e) prima) ‘Hata Series can include string, integer, flaat and none function all at one time ‘#Index can be assign by range function V= pd Series((’Ram", npNaN, 10, 20.7) index = range(4, 8) print(V) Payal 45, Sujeta 27 Joya 35 cdtype: into 244 b 57 © 8 d 74 2 89 ctype: into 4 Rom 5 NaN 6 7 207 type: object import pandas 0 pd Hata Series can be also formed by dictionery ‘Hata type can be decided data = ("Thyme" : 70000, "MI" : 45000, Ren”: 65000, "Kavin® 68000) F4 = pdSeriestdate, dype = 'float32") Faiindexname = F4 Thlond* prin(ra) print Length fen(F4)) 4 Thailand ‘Thyme 700000 MI 450000 Ren 650000 Kavin 680000 ype: float32 Length : 4 Import pandas as pd ‘string in ist() ore printed separately in form of each letter L= pd SeriestisnLucifer") print) ype: objectTn[26) import pandas as pa Import numpy as np ‘#orange function in np give data series with default index number and data starting from 2 to 22 with 3 as difference betwee X = mparenge(2, 22. 3) Y= paseriestx) print”) orange function includes float parange(2, 16.1, 3.5) K= pa Series(Q) print(k) Halse includes subtraction(24 to 6 with difference of 3.5] “ 7 20 dtype:int32 2.0 55 2 90 3125 4 160 type: float64 o240 1 205 2 179 3135 4 100 5 65 type: floate4 ° 1 2 31 4 5 6 In 22) import pandes as pd import mampy 0 mp Horonge function in np can als be used to form list In(33} Hlinspace function works...Check in Textbook P= npulinspacel2, 12, 6) Q=pdSeries(P) print(Q) 0 20 1 49 2 60 3 80 4 100 5 120 type: float64In(37} In} Import pandas os pd Import numpy os mp ‘tile function in nunpy gives the word 4 times as mentioned S = pdSeriestn,te("Ram*,4)) prints) ‘tile function with list form gives each etter repeated 2 times as mentioned = pd Seriesinp. tilelist(Ran’),2)) print(5) 0 Rom 1 Ram 2 Rom 3. Rom ‘type: object z ° 1 2 3 4 5 ae rae type: object Import pandas as pd ‘range can be used for index. Here itis from 1 to 12 leaving difference of 3 in between #100 written in data will be printed forall indexes V = pa Series(i00, index = range, 14, 3)) print) ‘string can algo be used as indexes but in ist form V = pa. Series(33.3, index = (Nina, ‘Zan’, au!) prin) ‘Hbifferent numbers as data and different strings as index can be used by list form W= pd Series({15, 65, 20], index = ['Shanaya’, ‘Abhimanyu’, ‘Rohan’ J) print(W) Hlst() form can be used so that written string is printed each letter separated X = pd.Series(ronge( 19,3). index = ist (‘TIGER')) print) #other then list() form, we can also used [x for x in") form Y = pa-Series(range( 15, 4), index = [x for x in"LION"]) print) 1 100 4 100 7 100 10 100 13 100 cdtype: into Nina 33.3, Ten 333 Paul 33:3, type: float64 ‘Shanaya 15 ‘Abhimanyu 65, Rohan 20. type: int Tt 4 67 E10 RB drype: into wt r5 08 NB type: intoTn [11} import pandas as pd Import rumpy os np ‘np Nan function from numpy can be used for no value. And when used, other integers are written in float form K = pd.Series({90, 100, npNaN, 200, shiv") peintte) 2 90 1 100 2 Now 3 200 4 Shiv ddype: object In[17} import pandas as pd ‘#uhen list is multiplied, values are repeated by repective number And when data series is multiplied, vlues are multiplied by repective number list 6, 8,9,12) # print(A* 2) type: into In[21}- import pandas as pd import numpy 0s mp ‘this can be used for multiplied value of index or data written i lst form) r 12,5,9, 11,15] P = pd series print) De 2, index = 1) ‘#function’**" is used for exponent(power of given number) C= pa-series(data = print) 24 5 10 9 18 M2 15 30 type: int32 20° 400, 45 2025 70 49.00 95 9025 type: fleat64In(34} In(33} import pandas s pt import numpy os mp Trd= mparange(®, 21,3) d= ['Sie’, Rayna’, mpNaN, “Tes P = pd Series(dote = 6 index name = “ABC Piindex.name = ‘mocks print) print(index) Print(®volues) Print dtype) print( shape) Print(®nbytes) number of rons 8 print(P.ndim) Print size) Frint(Pstemsize) not to be used or asked as per syllabus print Pempry) print( P.hasnans) marks 8 Silas ML Rayna 14 | NoN 17 Tessa 20. Sybil Name: ABC, dtype: object Inté4Index((8, 11, 14, 17, 20), dtypes'int64' names "marks') ['Siles" ‘Reyna’ non "Tessa! Sybil] object ©) 1 5 False True import pandas as pa import rum os mp A= (7, 40,61, 80,97, np NON] 3d Series(A) Bingexname = "ABC* prints) Print(Brname) ff no rome is essigned, output is none pont(.index) prinB values) prinv(®.drype) Print(® shape) Print(Bnbytes) number of rows «8 prine(Bndim) prine@.size) prinr(Bhesnans) print(Bempry) aac 0 170 1 400 2 610 3 800 4970 5 NaN ype: floaté4 None RengeIndex(start=0, stop-6, step 17,40, 61, 80, 97. nan floats ) 48 1 6 True FalseTn[36} In138} In(47} Import pandas os pd Import rumpy 0s np 80, 70, 60, 40, 33, 75) 100, 23, 44,56, 70, 10} Z = pd Series(Y, index =, dtype = "short") Zindexcnome = "ABC* Zrame = "SVHS" print(Z) rint(Z.nbytes) #When short is used as dtype, number of rows is multiplied by 2 aac 80 200 70 23 60 44 40 56 33°70 75 10 Nome: 6VHS, dtype: intt6 w Inport pans 5p. Brame = "Rll number" print) peinn(Bl'b'D if index i twice, then output wll be both the values ‘it youwant values of more than ane index ct once, then are tobe used 1 The output willbe according the the sequence asked to print ‘And all values of each index wll be printed print(BUb','e' ‘aI 25 23 44 56 70 10 Nome: Roll number, dtype:int64 Nome: Rell number, dtype:int6 Nome: Rell number, dtype: into Import pandas as pd import rumpy 2s np parange(O, 34, 2) rh Series(A) printVILI2, 7,2, 10]) # indexes in) wil be printed from choosen data series ararge(0, 8,2) 1d Series(S) print(G[1: 9:1) # date can also be choosen by toking indexes in range 1 24 7 14 24 10 20 type: int 32 12 24 36 type: int 32In(50} In(2} Import pandas os pd Import numpy os mp P= V{0: 9: 2] #° here is range whose value will be output from data series V by its index print) z % 20 type: int32 32 ctype: int32 oo 28 46 type: int32 Import pandas as pd import numpy 0s mp A nparange(5, 20,2) V= pd. series(a) print(V) After updation by assigning the index numer whase data isto be chenged VI0-7: = 'NNN # by giving range of index whase dota sto be chonged ‘Both ofthese method canbe used for replacing data print) 05 17 29 3 4B 5 6 7 4 ° 1 2 3 43 5 mr 6 7 19 ddype: objectIn(66} In(67} Import pandas os pd Import rumpy os np HEAD and TAIL factor A= mparange(5, 25,2) V= pa-Series(A) print) prinr(Vhead(7)) print(V ik?) 3 type: int 32 import pandes as pd import numpy 2s mp ins 1,5,3,6,2) 4A = (20, 30, 40,50, 60] ‘A= pd Series(data = dA, index = iA) print(-Data Series A is") prin) Bet, 2,3,4.5] a8 = (200, 360, 400, 500, 600) B = pa.Series(data = d®, index = i8) print(Data Series 8 is") prin(@). Cr A-8 print(-Data Series Cis") print) Data Series Ais 120 5 30 type: into Data Series Cis: 2200 3600 4400 NaN 6300 ‘NaN ype: float64In(67) import pandas as pd Import rumpy os mp print(V) rint(ViV>65), ‘#for specific intervalic value, we can used (dataname[dataname ‘«‘or >" or '=' number]) OP = [38, 30, 7,18, 0,55] QR = pa. Series(OP) print(QR) Print(QRI(QR>30) & (QRe=90)) # using "relational operators 0 35 50 78 89 o 55 type: into 278 389 4 67 type: into 038 1 30 27 318 4 90 5 d 55 itype: ints ose 27 a 50 5 55 ype: inte In {69} import pands as pd import numpy 25 mp V=pdseries(ay print(V) print(VIV=="a') # for single value Print(V[(V=="a') | (V=='p')D) # for muttiple values Houtput willbe as per sequence of data series not assigned value ° 1 2 3 4 5 6 7 8 9 d o 5 d nn ° P P ype: object pes object 1p 5a 6 Pp type ype: objectIn{7O} import pandas as pd Import rumpy os np print(V) Q= V.sort_values(escending = False) print(Q) P= Visort_values(escendln print(P) ‘True) #output will be printed with respective index number ° 1 2 3 4 5 6 7 8 9 4 9 ype: int 20 ines Beevoanadewaaveort 7 8 5 4 2 1 ° 6 3 4 3 6 ° 1 2 4 5 8 7 8 9 20 ype: it In[74}: ## Reverse the oll elements in Series import pandes a pd import numpy as mp UP [90, 100,80, 0, 70} A= paSeries(.) print(a) Ureverse() 8 po.Series(L) print) © 90 1 100 2 80 3 50 & 70 ype: inte or i 50 2 60 3 100 4 90 type: intoTrUs} In(75} Import pandas os pd #for changing index ‘A = pa.Series(data = dA, index = iA) print(‘Data Series A is) print wr TV, V4] 8 printData Series Ais" pine) for rearrangement of data as per index indA = (0! 'b''p',"9'F] data = [22, 33,44, 55,66) P= pd SerieS(deta = daa. index = iA) print(Dota Series Pi print). inc @ print(Dota Series Q is") print(Q) Data Series Ais 2 20 b 30 type: into Data Series Ais I 2 i 30 mr 40 WV 50 v6 ctype: into Data Series P is: a 2 b 33 Pp a4 955 F 66 type: into Data Series Q is: p 4a 455 7 66 2 22 b 33 type: into Import pandas as pd ‘#for dropping or removing particular data by index prinf(-Data Series Ais") prin(a) ropt'9') prin(A) Data Series Ais: a 20 b 30 p 40 2 50 60 drype: into a 20 b 30 9 50 60 type: into
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6124)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (933)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8214)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2922)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2619)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2530)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel