ret2.loc[ret2['INNERCODE'].map(lambda x:x[0]=='6' or x[0]=='3' or x[0]=='0' ),:]和matlab不一样的风格 - -直接用filter更方便ret2 = filter(lambda x:x[0]=='6' or x[0]=='3' and x[0]=='0',ret)用好map , filter, reducepandas,numpy,list要分清楚pandas有.map.filter没有iterlist直接用map
#英文字串首字母改为大写 st = "string" St = st[0].upper() + st[1:] 2016-10-22 后来了解到 python 内部有相关实现,感觉 python 好贴心~~~ >>> "hehe he hehe".capitalize() 'Hehe he hehe' >>> "hehe he hehe".title() 'Hehe He Hehe'
#coding=gbk ''' 输入字母,打印出要输入的星期几: 首字母无效,则继续输入,最多2次即可判断结果:否则退出. ''' week_list=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'] ss='' while 1: s=input('请按顺序输入星期的字母:') result=[] ss+=s.strip() for i in week_list: if ss==i[:len(ss)]