• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
oooooolr
You can do anything but not everything. ——David Allen
博客园    首页    新随笔    联系   管理    订阅  订阅

pandas

df = reviews.loc[:99,['country','variety']] or df = reviews.loc[[1,2,3,4],['country','variety']]
df = reviews.loc[[0,1,10,100],['country','province','region_1','region_2']] 两颜色不能互换,必须index在前
iloc index loc lable
top_oceania_wines = reviews.loc[reviews.country.isin(['Australia', 'New Zealand']))&(reviews.points >= 95)]

top_oceania_wines = reviews[reviews.country.isin(['Australia', 'New Zealand'])&(reviews.points>=95)] #no using of loc

 

Use the unique function to get a list of unique entries in a column.
countries = reviews.country.unique() returns ##array
countries = reviews.country.drop_duplicates() #returns series 

 

ser1 = pd.Series([1, 2, 3, 4, 5])
ser2 = pd.Series([4, 5, 6, 7, 8])

ser1[~ser1.isin(ser2)]
ser1[ser1.isin(ser2)]
ser1.isin(ser2)

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- focus on what you want to be
posted @ 2019-03-24 19:17  oooooolr  阅读(165)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3