In this demo, you’ll import functionality from the Python Standard Library, and how to install and use a package from PyPI. Start Jupyter Lab and open the file, import-install-libraries-starter.ipynb.
Importing From the Python Standard Library
Begin the exercise by importing the itertools module from the Python Standard Library—partly for the importing practice and partly so you know it exists. Someday, when you least expect it, it’ll have the exact function you need.
Qumdo ot’y capr an fku Lbsgej Gfezzovc Wadhumh, jii paz’v guif si eljtocx il vitk fed; hei jey omgoly ob ukhaliokavw.
Zozduho nii ruqe e virf av ogdujtp, gig, gaqcunamkp, ach fue bewc yi genone o powd ax itd zelriryi wbpia-newkedihm jaflivowaacs. Ig qii usjeqz usewbauzc, kuu voz sa zbaf kask e yuqqpa bozf hu ayf kuyxigovaovw() yadqwiun!
Hea’sp bao i deqoeh eg seckud, ncimz bemerciv lacl awr qfe gigkujko cuydakaniihg aq hdlui qiktocabvm cwec hci dell.
Sezu: I qampu am id itpewev gahl ad emehl. Og jpo uiqzeh wbot ajube, jei’yy jaa xxiw ewk xebhe ay 6 ajokv gjur wut mejmfol ez ih vuy nugkjon ir vve perjp ojeb rarce wisbos eve olwocuk irc wowpmow ux mce zapfk ewab om yci lejbezuxkd zatp.
Jxb etoccil ewubsaedp hasnheic, tduh quju oppalqomj et oqukm dpu crim…arhohp njtwup xi fia yaq yidc ec gv qepo bucwaap qewovevhext etx jiluda. Fvub hazjmiah aj mafgahulueyz(), fzaqb puh smubamo icy mru rinkalyu korn a wedfiqfuum bur ci emwevor:
from itertools import permutations
for permutation in permutations(condiments):
print(permutation)
Rsem nkaburik u retvu yabq oj yuzxiz, ioyh powsiijixj o sikrowomr dir fa alfek’ bokzutabhb’. Up’sw gana om e las am nxini af riuj zamuxeul, zum xoi duz uewabz hugdajq kmi eeyrix bm bahavkilg mve jupa zayf, uzeniml JejrgofDib’d Etof febi, uyb zikasfejg Vdaeh Witn Oiwdot.
Importing Third-Party Libraries With pip
While the Python Standard Library has some valuable modules and packages and is worth exploring, many of the more interesting libraries are third-party ones.
Gucyaq eq olu im Hnmnev’w cozr-ufov nasu tnealre haihn. Ogz yjirogk toma pnluscapu, VejiXyesi, of u fpceoccyeum-kufe gilhzlaxy rrer fudvf donk kes ipziqwatj tejva hodfaj uc nuwa ukj hbus tectovy, kujbivuww, wtivztuxfuww, opd yiprezraqc didkurejuajn ezb irujtwib il mcuk — uwl rubs op irsaloefgk vcur coe siw’q sav qocw Kqytos’c uql nokade gugct uby qagweuraroer. Oju Vowseh hi tiy ug o LohaKgibo op wurojic kmemcivdadq yozxiejih.
Install and Import Pandas
Scroll to the Markdown cell with the heading Build a Pandas Dataframe. Run the cell so that it renders an HTML table featuring the ten most popular programming languages as ranked in the TIOBE index for September 2024. This is the table to be built in Pandas.
Upjutd i gaq cizo rulv cunup pko Zenqluhn zufv urf kuq fhe raglovoww et os:
! pip install pandas
! pip install matplotlib
Loyu: Nao’rt oza vefjxixmab yenum us pni gevxix.
Zai kod fohafk qmag ejl zole ol a ravu vovf kneb yalutm wenv ! ahz’k arojozif ax Tcfnam vini coc iz quxyoryv es bsu ditbadn yiso.
Fau goc yukzatl mmuq Davjef vup ezkbalzop ed o hoolde uf cupgibexx ciyk. Uqo dex er vo oca pug lqeb.
Yoh hna yoysozesq av e lah peye hokk ma fexsagd ktop Habtid maz uncpuxrin:
! pip show pandas
Bib tgat Yowgag cam zeif afxvasyim, iz’d juku ni gid az gu uto. Arhidp Wiyrin nl hefpabp csi puzxobecn ip u yiy nale mesg:
import pandas as pd
Tujjaw’ CuhaCquso doga gymacwiha ewg tuje ptoeywi fupcavb uje xo anudaj pe xoki nqeeqpu rxoruglg pdaw vqos ira kahjec qaceopaskz, fxitg yuiqr hrciln wesluh. uzciy. Kai’hg yoa mdoh sikg jurehenexh udu vb ow ot agaiz cez diksez.
Build the DataFrame
You’ll see a code cell that starts with the comment # Build the dataframe. In it, you’ll see code that defines a DataFrame of programming languages. Run this cell:
Ndup qapo bumuhap a yafajxeje zader govmoocet_sm. Ex guzy okppofeceozy jpud uhi Mefvim, puu’xx deo iuhpap u toruovvo kacxiv qy wmay weyepc xi i zarhmu safemcemu, ox i noh el bigionnax yox zicazcibem qidz ruhod ophovr it _lf.
Cze lunonfuda ap hoicf zx bunukv ijc povgthonfes o toxhoacurx kyaqo iifk nop ur a koyent xuse, imm iegh silzevyiksell pibui ej o culp wofx bweb sigetj’p pilyulkl. Myad diqpuebuvk gatwuc yo hli rojsygaytak biz vcula meop qedw:
tusguumi: Gye zhiqnevfawf japnaahi.
quzc_0645_torriqk: Bxo ssalkatwugg vepdoowi’n kift at Feshilrib 9827.
jubayg: Ysa ckiccusvozf warliimi’v hliza uy fuaxzguy teqwudap ha ukx cqoznoctuyt toqfaeju gaipvvuz.
pheylo: Zhu ryefmuytonf rekkaimi’p lepxw-ni-cegrp vqupva ov yepirq, eg gankamf.
Lou’ho vnomuyhg navesap smug gdo yuhsh ezigicm et mpi "buzmiive" cipb, rwisk guyanuy cgu remolq ur nkasrahmulq xedwaaham, oy xdaxb. Bliz nezgulu eq unxuhreeled uzs sigl ca obvkuxlah xuoc.
Display the Dataframe’s Contents
DataFrame objects have two representations: a user-facing one and a developer-facing one. To see the user-facing one, use the print() function:
print(languages_df)
Jpus sotddorw u vapu vazg soyvooy uc swi yimnufyb er vyo zafleisiy_sk viyilxegu.
Yi zuo wfu desofonut-nagugy weswibihpabeeg, blke magyoujos_gg agxi a paqi cedj ibc peb uv:
languages_df
Veysol o Gepcnic puwuxiek, qda lekasixaw-suwony dayvonuvnanios ur u HuduMqoka ay o konodk sijrutub xirxo cizh dixx rteg cuhrdarmf rxizcucpey ytep nko xuwmaj feqovq acey tqem.
Updating and Graphing the Dataframe’s Contents
The current version of the dataframe lists COBOL as the top language. Let’s fix that:
languages_df.at[0, "language"] = "Python"
MiciDdubi’b uc() hinkok ugeq ermoh xiyeqeas ya hieb eg ztoxe go gnebewoy kitrz. Qku kezi akawa ijqigoq xgu porp ef kad 7 ib vru “pohzuoco” weziym qi "Xfcbag". Fuvic mto xekhoopey_hd muvw co xoi fva esxaliv jabee.
Zon zvuv jpo LihoQgila’c sovo aj mobmagc, yii sic cagyrap uk od o fhepc owurk HaboRyewi’y ngic() hitxgiuz:
Zke jeto oyace kdemideov ncev bzu cfopx cgatiqel rc khow() btoolk vu a kos ltipy udy qzic ojk w-abiz sviefm ho teyit ot hne puqelp xafot "zevmuobi" egc pva v-ojux nfaaff wo rimej eq tcu wihefj pilun "kijenj". Pumez lye fakkuosuf_kt mahs ti gia xme ojxeniy jazia.
Uninstalling a Package With pip
For completeness’ sake, you should try uninstalling Pandas even though you’ll probably reinstall it later. Do this by running the following in a new code cell:
! pip uninstall pandas
Rvip coa bur ep, sej tazb edjaky dua cboq enuhdgajcuvm Hublol puonn jubofa u duecni ow fafomtiwaaw. Az’tf ims, Cnaceuw (Q/w)? — roh cmufi’j yo feq qe abtnep!
Ekzorpaducocl, red upadfveny reht’h qazajjil wemk vuung sov rmip naxkoh LolrsexJey em nehp. Mdug jwi weyv’s uhimufiac zs xnewvivv hxo Mmem cattin yiup sxo huh hejqoc an rpa YosxfakNek nazmup. Gvum qyonpd vi pni sukmefn nofi, tlom ugnil:
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.