99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2021-02-28 閱讀量: 539
pandas如何用布爾值索引

問:

pandas如何用布爾值索引


答:

布爾索引是一種索引,它使用DataFrame中數(shù)據(jù)的實(shí)際值。在布爾索引中,我們可以用四種方式過濾數(shù)據(jù) -

  • 使用布爾索引訪問DataFrame

  • 將布爾掩碼應(yīng)用于數(shù)據(jù)幀

  • 根據(jù)列值屏蔽數(shù)據(jù)

  • 根據(jù)索引值屏蔽數(shù)據(jù)


使用布爾索引訪問DataFrame:
為了訪問具有布爾索引的數(shù)據(jù)幀,我們必須創(chuàng)建一個數(shù)據(jù)幀,其中dataframe的索引包含一個“True”或“False”的布爾值。例如

# importing pandas as pd

import pandas as pd


# dictionary of lists

dict = {'name':["aparna", "pankaj", "sudhir", "Geeku"],

'degree': ["MBA", "BCA", "M.Tech", "MBA"],

'score':[90, 40, 80, 98]}


df = pd.DataFrame(dict, index = [True, False, True, False])


print(df)


輸出:



41.0846
0
關(guān)注作者
收藏
評論(0)

發(fā)表評論

暫無數(shù)據(jù)
推薦帖子