Thisone, uh, andkindofcombinedtootherdatasetsjusttoSeymouraboutthiswholerelationshipsthingandlearn a fumeorcoolfeaturesofpandasbefore I finalizethislittleminiserieswithdoingmachinelearning.
Ah, basically a machinelearningworkflowwithpandasinthenextvideo.
It's prettyhardtobasedonthatdataloan, drawanyrielconclusions, we'rejustdoingitto c t learnmoreaboutpandaswerereallySoifyoufindyourselfoffendedbytheresultsofthisvideoum, notmyproblem.
Soanyways, herewegoimport, import, importpandasas p d.
Andthenwe'regonnabringinunemploymentcountyas p dotReadunderscorerSissiAndthatisdatasetsslash.
Soinsteadwe'llsayAtzmonwageequalsactminwage, uh, droppinginandthenactmehadfixedthatcapital w Okay, great.
Sonowwhatdowewantto d'oh.
Sowewanttotaketheminimumwageandwewanttokindofaddthatto a newcolumninourunemploymentcountydataset.
Sotheway I think I wanttodothatisbycreating a newcolumnandthenmappingthevalues.
There's probably a betterwaythanthis, butitgivesmetheopportunitytoshowyouguysatthemostbasiclevel a methodthatwillalwaysworkforcreatingnewcolumnvaluesandpandas.
Thiswasnotthemostefficient, andinfact, it's goingtoprobablytake a moment, probably a minuteortwotorun.
But I'm gonnashowitanywaysbecauseitalwaysworks.
Andthenwe'lltalkaboutit, willshow a coupleotherexamplesthataregoingtobe, like, wayfaster.
Butanyway, uh, getesoit.
Let's dodefine, get, getyoucan't wageon.
Thisis a functionisgoingtotaketwoparametersisgonnatake a yearandbystate, sorecallminimumwagesbystate.
Nowwe'regonnamapthisfunctionto a newcolumninpandas, andthewaythatwecandothatisjustlikeregularmappingfunctioninpythoningeneral, sowecanmap a functionto a listorarrayinpythonusingmap.
Andthisislike I saidbefore, notgoingtobethemostefficientway.
Butthisis a waythatwillalwayswork.
Especiallywhenyouhavethingslikefunctionswithmultipleparametersoryouhave a funlikeyouwantit.
I didn't thinkthatwasgonnaworkbecauseas I thinklikePython, I usedtoworkandfightontwoandthenwithpythonthree, youactuallyhadtodolistmap?
Nowaythatworked.
No, yougetuh, that's hilarious.
That's adorable.
Okay, soyeah, wedohavetocatchit.
So I'm planningtoThatactuallyworked.
Youdidn't get a mapobjects, soactually, wehavetoconvertthisto a list.
Oh, thatwassoexciting.
sofast.
Okay, soitactuallybecalculated.
Herewego.
Andthenwheneverthatisdone, I justwantit.
Wecouldalsoseewhenitgets a number.
But I'm justgonnado a nymphocountydotheadhere.
Cool.
Okay.
Soagain, allthat's doingiswe'rejustwe'reconvertingitto a listattheveryendbecausethat, youknow, withwithpandas, youyoucouldjustsay a newcolumnis a listofthings, anditdoesn't matterhowyougeneratedthatlist.
Itdoesn't havetobeviapython.
Well, itdoesn't havetobeviapythoninitially, I guess, butdoesn't havetobeviable.
Pandoes.
Okay, umbutyetsothisisgoingtorelativelyslow.
Ifyoucando a dotmap, that's great.
Otherwise, a dotapplyorsomethinglikethat.
Therearesomeotheroptionsforusandall.
Kindof a show, anoption, anywaydowntheline.
Butoncethat's done, cool, wearegoodtogo.
Sothefirstthingthat I woulddooncethatisdoneis I wouldjustchecktoseeunkemptcountydots.
Um, Andthenifsomeoneknows a quickerwaytodomultiple, like a quickerwaytomap a functionwithmultipleparameters, soitcan't justhaveoneparameter, because I know, yes, therearequickerwaysofit.
Well, we'regonnasay D f that's left a setunderscoredindex, andwearegoingtoset a doubleindexweregoingtosayCountycan t comeonandwhoopsoverDidn't screwanythingupstateandthen, uh, inplaceequalstrip.
So, uh, hisrelationshiptoelikeminimumwageandpeoplewhovoteforGaryJohnsonmightbesignificantlydifferentbecause, like, hewouldbeprobably a proponentofnominimumwage.