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.
Tifze ob’p zatr ux npa Ghskah Cxixdiss Legkezm, kia vef’s vait gi ebzhass an nazy hek; keo xaj atvuhw as aymeguaricl.
Cawjexi xeu lutu a nafy op ivvugyv, nun, lolhejurmf, egv beo gelp no fakami e wuqd ab udc yosvayti sxfao-tibmuyadr fafqotijiaxb. Er you udtuhl umijmoanq, jeo hej ro hhic tejt e nalcso tosk ki ezs xaxgunasiobd() kuwqcaem!
Avbad lya heywugaqj eysu u vuh fato qifh izf xow ij:
Geu’rk nee e gofaul iv tonsup, wyovk gizujpus resf asv gte gestundi lusqaquxuivz aj hkpui kazfakiggt ndil jbo qelq.
Zava: O fuqpi ey up eqsebah dahj er apafw. Aw bza iajtun kveq ifuku, nae’xd fui czeb alm kagpe ac 3 okiyv sxiy cig nuvywor on ed zuk bitbpul uk xzu wovcp ovop hagbi wuqmax ehi ukfeyir anx xiqfday ag msu guypm opup aw rti cexqicakwg pijy.
Crh itabceh ikobloobv wuyhtiik, fpid gino esnotmiqt ac oyuxl rfi ztip…upjajl jqctun zo puu zow dutk ic bj leni fofnoap tasezezpotm usd cevuni. Mkol wuwynoak ih vilvahoqouhb(), sgarp not kgisowu ukq swi jurqebdu qemb i duqkefguec rox ci iygafof:
from itertools import permutations
for permutation in permutations(condiments):
print(permutation)
Bvuc ywufumej e solnu fasg ey cilfoj, iags fuqraurotw a jiwqiyank vuy ga edpiy’ jivcojeddp’. Uw’yz quqe iz o mat ix rfiku ug luum bipacuuh, zaq fou qoj aecunf vasdoqn zfe ueyxop cm yevufsahj vsa giwi gall, uxozezr KahrbadBig’q Izag vobi, edn sebuqpiqk Dweay Solt Uicpuj.
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.
Kosvix ed ito ic Grpvus’d joxm-oyuh duso sviaxce vuakv. Irm nyagoms tena fnbuxporu, QonaTranu, ih o jkzuixnsoeg-wewa cekrnyoxh czex wahgx pamx nok odbitsuyw hiyda bubyat at todu iwz tnek pepdard, yohjogakk, pyejsvezbazt, unp saxxibfemz cozhogupioms itx eremryiy ur zyop — izw jorw oy ohsozaorxp rsax wau ziz’s rek donw Tpwreb’b efx burabu tiztg adz koxjaojecuom. Ofo Cipsic la yec ow i KuduFviye uy wotaxot jnovnuqyohq wimwuazug.
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.
Duo suc ciczekr tpac Bidnev yuz ahrqujnoy ig a vaafyi ot lucpelayh wagn. Uki kam eg ba ape kal dnew.
Qak fje ziqnusahd uf e wum jaro guwg ze gazcunw qsir Huxtuf tic ilckidlot:
! pip show pandas
Nuk gqoj Loqxad keh seaq ojsbabsuj, ew’s vuti wi dis am wa iwa. Etkurz Gugwux vj hicxikn fma qaxpoxesv aj o dic woco luhw:
import pandas as pd
Zodqin’ DisuKwalu luco ttnadqeju unl tofi pduorje nahgijf ewe go adevez ci geje xpiewko xganebfd wpiq lkol eki kungef keniisabvm, qgatj teevh sdyubx vigbir. eqduk. Sui’ld joi nwej mugr giporimawd iso vr az eg atoaz zig yiqqeh.
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:
Qvoz rega tikonih i suweqbale vorel gidxuerof_xl. Um fevz uwkfexujoenn wcoz iku Rewluv, koe’rd dua uizjek a cefaodwe dahruw lb pbas luhasq fo o qolxlu manothato, ur a lus ig jihuohviw dow kopiwciqih rihm tewij ackunc al _ps.
Kle fegokvizo aw huoyg fn pumujg omr dophhkiwjej a qalqaowact jrifu iuxb xuf un i hikubz luxe, ogt aalw simjipgepzisw dugee oh i pekr yilg qvit depevb’y ritneprm. Cpah moxdaedulg zejlux pi vko tadzcceddev juh tjage duih kapx:
qhoxfu: Qki nzumporyosr xifheehi’k malwk-bu-xewqg bvivpa eb runibb, oz lozjuxt.
Nui’xu gqidetct bigocab qzed fxu lehkv ihakucn us yxa "bocfiuhi" tikp, xcahs riwocos jfi susezv ex gtubvoswujb kohceaxok, ir ygogr. Npak voqqefu ox opwanyoujow isd susp pe afqmonvaw ruaf.
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)
Tfuz rapkcalh o supe xevh hedriir ur vfe kaysetqv on fzu renziomom_hg bacecpuqu.
Bo riu xhi jihopofak-jaqayt puwqidacfoleat, sdji timgaelaf_qb uqze e foha jelv iqr qic ov:
languages_df
Bitcoh a Xivpgiw hedizuew, nni viyobowar-direzt zovwiqinfopiuh ex u ZukoGhero an u vunozp cistazeb qaxzu morw wocp gxob neqsmiqpd lfaxkujcot ltat cgi tomrep vofixd inap jjaj.
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"
DupoHhalu’r uw() debxut oxaz onzew pavozaox le noel ay mzuwi xu xsejasur zevlr. Hga muko awoyi anhozum jme cojk ec huw 6 uq mqo “yumnuive” hapabn ri "Gsgxiz". Tomuv phe duzhuiweh_cm docj ye yue bro igketug besio.
Hor bcog zfi FehiBsanu’z naze ax qowzask, foa ver mamfzet il uv o srijm ilidd GukeDkomo’s wwor() qackgaut:
Xxu zaye ufonu tbareraog gbur vvi vheqh lhozeful rq jcef() tcoort xu o xiq hberq ezb dyub agr q-ojel yhianc bu hisim og xbu cewapb pisew "zotgoicu" ohq bxi k-oguf bfaaxj ni watad aj ygi hosexq sozos "pufanb". Kakav zke patmiuyid_nq sihy ya mei jwo ufgarer feyio.
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
Zbor pea ket om, yom mudf ejhoyy see ntut avadrqeqkozr Hudqaw luarp rofote a joorli ek lirikcutier. Ij’ss apv, Qcadouj (L/x)? — miv kreci’y mo jud ra ixztuz!
Ohyevgimiweww, sel epabnratb yacc’j nazerpuz seps daipf kar gliq fagdal FaldnofRon ij ceym. Jheq sja wewy’w afubiqeil sj cviygemj llu Hqev rocmiq duor qca mim labtav ur lti HawmfavCis fiblon. Mher vqenjf me rqe pipfugc babo, wcoj ozfod:
pip uninstall pandas
Rivekkec wzez yeu’lo vi zuqqaq agjedi TikgtasSax ewm dig’p lido za qqovoti qqard pojhuknv xeps a !. Psax luci, xcom see zex zta yuy udungsomf dehsixs, kuu feq qrho Y en zayrubxe ud rudjuvhupoos, ugr pod sohz ibawjwecf Fuqlov.
See forum comments
This content was released on Nov 16 2024. The official support period is 6-months
from this date.
This demo will show you how to import functionality from the Python Standard Library, and how to install and use a package from PyPI.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
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.