It's sciencetutorialwithpythonandpandasweregonnabecontinuingourworkwiththeavocadodatasetbeforeweleaveitfor a newandexcitingdatasetinthenexttutorial.
Just a fewmorethings I wanttoshowwiththeavocadodataset.
Uh, especiallyjustissuesyoumightrunintoovertime.
Solet's goaheadandjumpin s.
Sothefirstthingwe'regonnadoiswe'rejustgonnabasicallyrecreatewherewewereimportpandasas p d d f equals p D riPTRead C S v datasetsofkadodot c S v Albany D f equals D f eaglesDFwhere d f regionisallBenny.
NotallPandeyoften e d f dotsetindex, asdatesinplaceis, hewillbetrueinthere.
Finally, uh, AlbanyDFdonActually, we'rejustgonnadoaveragepricepricedotplotAnd I didn't lookupthecommand, uh, soldiersfromthistwiceandtherewehaveit.
Soprettygraph.
Butthere's a fewissuesthatwe'rehavingrightoutofthegate.
Andwhenyouseesomethinglikethis, itprobablymeanspandasdoesn't actuallyrealizeit's a date.
Sothefirstthingthat I woulddoisconvertthatto a datetime.
Sowhenwereadinthe C S V, ifyouactuallyhave a date, theprideofthebigthingyou'd wanttodoisgoaheadandjustsay, D f dateorwhateverthecolumnnameisequals p dottodaytime, Uh, andthen d f date.
So, um, thiswillprobablytrytothinkwe'vedonedoneoneinthe 1st 1 But I don't thinkso.
Well, it's Jupiterlabnow, butanyways, uh, probablywhatwewanttodoisactuallycreate a newdataframe, andtheyjustplotthatdataframe.
So, really, ourtaskhereistheseregionsarevaluesinrows, andinsteadwhatwewanttodoisactuallyalmost, like, reshapeourdataframetobe a dataframewherethecolumnsaretheregionsandtherose.
Well, thecolumnheadersaretheregions, andthevaluesofthosecolumnsarethelet's, say, the 25 movingaverageandthentheindexesdate.
Sonowwhatwewantto d'ohislet's justsayifgraffDFdotemptySobasically, ifthisdataframedoesn't haveanythinginit, thenallwe'regonnasayisgraft e f equalsregionDFandallwewantisthat 25 m a column.
That's theonethatwewant, but a coupleofthingshere.
Thiswillreturn a Siri's.
Wedon't want a Siri's.
Wewantthistobe a date a frame, sowecancontinueaddingnewcolumns.
Sothewaythatwetakethisis a slicethisHey, jerk, Notcool.
This, thatthat's a dataframe.
Sotheonlydifferenceiswe'vegottwobracketsandthenlater, ifyouwantedtospecifymultiplecolumns, use a price m a andthenyougowiththeaverageprice, likefortherawdata.
But I don't actuallywantthat.
I justwantthepriceofMayandthenwe'regonnasaysoifit's empty, thatisthatelse.
Whereis a graph?
T f equalsgraph?
DFjoin.
Sothisishowwecanbringdataframestogetheronanindex, andthenwewouldwanttojoinregion D f.
Otherwise, it's gonnabelike, that's exactlywhatitsoundslikebytheway d f typeequalsandthenwe'lljustgowithorGanic.
Okay, Thenwesetthedate, andthen, uh, let's do a d f.
So, forexample, uhsowhilewhile I haveyouguys, I couldjustsay d f thatsortvaluesandwe'regonnasay D ifthatsortofvaluesbyequalsdatesandthenwe'regonnasayusendingequalstrue, I believeBuyten.
Normally, it's actuallyfalse, I thinkisthedefault.
Andthenwe'llsayinplaceequalstrue.
SoSothisisjusthowyouwouldsort a dataframedby a certainvalue.
Soratherthanbecausebeforewe I shouldyoushortsortindex.
But I said, Hey, youcouldsortbycolumnstoo.
Here's howyoudoit.
Andthenlet's doDoyouhave a head?
Cool.
Andnow, um, Cohen.
JustWell, it's just a rateoverthis.
Sonowwhat I wanttodoiscomebackupherebecausewe'reactuallysettingindexhereanyway, Soletmetakethisfromappearcopy.