概述
取得DataFrame对象reviews的description列的前10个值(或者说reviews前10行的description列):
reviews.iloc[:10].loc[:,'description'] 等价于 reviews[:10]['description']
kaggles练习(https://www.kaggle.com/morein2008/indexing-selecting-assigning/edit)答案:
reviews.loc[reviews['country'].isin(['Italy','France']) & (reviews['points']>=90),['country','points']]
reviews.loc[reviews['country']=='Italy']['points']
reviews.iloc[:-1000:-1]['points']
reviews.iloc[:1000]['points']
reviews['points']
check_q9(reviews.loc[reviews['region_2'].isnull()==False,])
check_q8(reviews.loc[reviews['country']=='Italy',])
check_q7(reviews.iloc[:100,][['country','variety']])
check_q6(reviews.iloc[[0,1,10,100],][['country','province','region_1','region_2']])
check_q5(reviews.iloc[[1,2,3,5,8],])
check_q4(reviews.iloc[:10,].loc[:,'description'])
check_q3(reviews.iloc[0])
check_q2(reviews['description'][0])
check_q1(reviews['description'])
最后
以上就是寒冷白猫为你收集整理的DataFrame-选择与切片的全部内容,希望文章能够帮你解决DataFrame-选择与切片所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复