加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

Python数据说明-看了这篇文章,数据洗濯你也就完全把握了

发布时间:2019-09-16 00:24:22 所属栏目:教程 来源:哗啦圈的梦
导读:全部做数据说明的条件就是:你得稀有据,并且已经颠末洗濯,清算成必要的名目。 不管你从那边获取了数据,你都必要当真细心调查你的数据,对不合规的数据举办整理,固然不是说必然要有这个步调,可是这是一个好风俗,由于保不齐后头说明的时辰发明之前由于

13. endswith(pattern)字符串末了是否是特定子串 true

  1. s = pd.Series(['Tom ', ' William Rick', 'John', 'Alber@t']) 
  2. print ("Strings that end with 't':") 
  3. print (s.str.endswith('t')) 

执行上面示例代码,获得以下功效 -

Strings that end with 't':

  • 0 False
  • 1 False
  • 2 False
  • 3 True

14. find(pattern)查子串首索引,子串包括在[start:end];无返回-1

  1. s = pd.Series(['Tom ', ' William Rick', 'John', 'Alber@t']) 
  2. print (s.str.find('e')) 

执行上面示例代码,获得以下功效 -

  • 0 -1
  • 1 -1
  • 2 -1
  • 3 3

留意:-1暗示元素中没有这样的模式可用。

15. findall(pattern)查找全部切合正则表达式的字符,以数组情势返回

  1. s = pd.Series(['Tom ', ' William Rick', 'John', 'Alber@t']) 
  2. print (s.str.findall('e')) 

执行上面示例代码,获得以下功效 -

  • 0 []
  • 1 []
  • 2 []
  • 3 [e]

空列表([])暗示元素中没有这样的模式可用。

16. swapcase()调动字母巨细写,大变小,小变大

  1. s = pd.Series(['Tom', 'William Rick', 'John', 'Alber@t']) 
  2. s.str.swapcase() 

执行上面示例代码,获得以下功效 -

  1. tOM
  2. wILLIAM rICK
  3. jOHN
  4. aLBER

17. islower()搜查是否都是大写

  1. s = pd.Series(['Tom', 'William Rick', 'John', 'Alber@t']) 
  2. s.str.islower() 

18. isupper()搜查是否都是大写

  1. s = pd.Series(['TOM', 'William Rick', 'John', 'Alber@t']) 
  2. s.str.isupper() 

19. isnumeric()搜查是否都是数字

  1. s = pd.Series(['Tom', '1199','William Rick', 'John', 'Alber@t']) 
  2. s.str.isnumeric() 

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读