python数据分析之pandas(11)排序和字符串处理

1.take排序

take()函数可以理解为对frame对象按照给定行按顺序抽取
frame.take([2,1]) //取index为2,1的行

>>> import pandas as pd
>>> import numpy as np
>>> frame = pd.DataFrame(np.arange(9).reshape(3,3))
>>> frame
   0  1  2
0  0  1  2
1  3  4  5
2  6  7  8
>>> frame.take([2,1])
   0  1  2
2  6  7  8
1  3  4  5
>>>

2.字符串操作

text.index() //字符串查找,找不到报错
text.find() //字符串查找,找不到为-1
text.count() //统计次数
text.replace()
re.findall()
re.compile() //编译正则
re.split()
re.search()
re.match()

发布了127 篇原创文章 · 获赞 10 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/u012599545/article/details/104400888
今日推荐