DataFrame Loc yog dab tsi?
DataFrame Loc yog dab tsi?

Video: DataFrame Loc yog dab tsi?

Video: DataFrame Loc yog dab tsi?
Video: Data Science with Python! Sorting pandas DataFrames 2024, Kaum ib hlis
Anonim

Pandas DataFrame : loc () ua haujlwm

Cov loc () muaj nuj nqi yog siv los nkag mus rau ib pawg kab thiab kab los ntawm daim ntawv lo lossis ib qho boolean array.. loc feem ntau yog daim ntawv lo raws li, tab sis kuj tseem siv tau nrog boolean array. Ib qho boolean array ntawm tib qhov ntev li qhov axis raug hlais, piv txwv li. [Teeb, False, Tseeb].

Tsuas yog li ntawd, kev siv LOC hauv Python yog dab tsi?

loc txoj kev yog ib txoj hauv kev uas tsuas yog siv cov ntawv cim npe thiab xa rov qab kab lossis dataframe yog tias daim ntawv teev npe muaj nyob hauv tus hu cov ntaub ntawv. Txhawm rau rub tawm CSV siv hauv code, nyem qhov no.

Kuj Paub, qhov txawv ntawm ILOC thiab Loc yog dab tsi? loc tau kab (los yog kab) nrog cov ntawv tshwj xeeb los ntawm qhov ntsuas. iloc tau kab (los yog kab) ntawm cov haujlwm tshwj xeeb hauv index (yog li nws tsuas yog siv cov lej).

Tsis tas li ntawd, loc txhais li cas hauv pandas?

1. Kuv twv loc yog qhov chaw thiab iloc yog integer qhov chaw. Lub assumption yog qhov chaw sawv cev rau qhov tseeb indexes yog dab tsi. Nws siv los mus ncig kuv vim qhov ntsuas thiab cov lej pib nrog "i".

Loc thiab ILOC yog dab tsi hauv pandas?

loc yog daim ntawv lo-raws li, uas txhais tau hais tias koj yuav tsum qhia cov kab thiab kab raws li lawv kab thiab kab ntawv. iloc yog integer index raws li, yog li koj yuav tsum qhia cov kab thiab kab los ntawm lawv cov integer index zoo li koj tau ua hauv qhov kev tawm dag zog dhau los.

Pom zoo: